1、struts2
spring
hibernate
几个重要的注解annotation
(1)表示将action交给Spring管理
@Component == @Component("testAction")
<bean id="testAction" class="com.myivtec.web.TestAction" ></bean>
@Component
@Scope("prototype")
<bean id="testAction" class="com.myivtec.web.TestAction" scope="prototype" ></bean>
2、数据库中的常用注解:
(1),@entity(name="tablename") 类注解
@entity
默认的entityname就是类名
告诉hibernate 我这个类需要和数据库对应 对应的数据库表名为tablename
(2),@Id 属性注解
指明该属性是主键
(3),@GeneratedValue
指明主键的生成方式
是 有hibernate帮咱们指定
如果数据库是mysql 主键生成方式就是 auto-increament
如果数据库是oracle hibernate会帮我们建立一个 sequence (hibernate—sequence)
总之 id 会有hibernate帮咱们指定 咱们无需管
(4),@Column(length=10000)
length 用来指明字段的长度
@Column(length=10000,name="test_content")
name 指明数据库中字段的名字
(5),多对多的关系 这个是后要用中间表实现
teacher
id
name
student
id
name
teacher_student
teacher_id
student_id
@ManyToMany(mappedBy="studentes")
mappedBy设置关系的被维护端
(6),多对一的关系
学生和班级
student
id
name
class_id
class
id
@ManyToOne 多对一的关系
@OneToMany(mappedBy="classRoom")
一对多的关系
mappedBy设置关系的被维护端
name