Hibernate注解

hibernate注解:

@Entity //创建类对象
@Table(name="t_dept1")// 类与表的映射,相当于 <class name=".." table="..">
public class Dept {
         @Id//主键映射
         @Column(name="did")//指定映射表的字段id名称
         @GeneratedValue(strategy=GenerationType.AUTO)//以native的方式设置主键的值
         private Integer did;
         @Column(name="dname")
         private String dname;

@Entity
@Table(name = "t_emp1")
public class Emp {
         @Id
         @Column(name = "eid")
         @GeneratedValue(strategy = GenerationType.AUTO)
         private Integer eid;
         @Column(name = "ename")
         private String ename;
         @ManyToOne     //多对一
         @JoinColumn(name="iiiid")
         private Dept dept;

HQL:

 

 

posted @ 2017-05-31 11:12  路迢迢  阅读(279)  评论(0编辑  收藏  举报