hibernate annotation&ID生成策略
来源:互联网 发布:plsql写sql时中文乱码 编辑:程序博客网 时间:2024/05/22 11:44
Annotation 注解
@Entity 实体类
@Table (name="")表名与类名不一致 注明表名
映射枚举类型
@Enumerated(EnumType.String(String类型存储)|EnumType.ORDINAL(int类型存储。顺序))
字段映射位置 如ID
@ID 1.放在filed(private int id)上面 2.放在get方法上面
建议放在get方法上
@ID
public int getID(){...}
ID生成策略
xml
自动生成ID
<generator class="native"></generator>生成器
identity 自动递增
sequence
native 最常用 自动递增
uuid 生成一个全球唯一ID
使用Annotation
@GenerateValue 生成策略默认相当于native
@GenerateValue (strategy=GenerationType.IDENTITY) 指定策略
联合主键
@Embeddable 主键类
@EmbeddableId
@IdClass(value=xx.class)
eg:
@IdClass(studentPK.class)
public class student{
private int id;
private String name;
@Id
public int getId(){...}
@Id
public String getName{...}
}
@Entity 实体类
@Table (name="")表名与类名不一致 注明表名
映射枚举类型
@Enumerated(EnumType.String(String类型存储)|EnumType.ORDINAL(int类型存储。顺序))
字段映射位置 如ID
@ID 1.放在filed(private int id)上面 2.放在get方法上面
建议放在get方法上
@ID
public int getID(){...}
ID生成策略
xml
自动生成ID
<generator class="native"></generator>生成器
identity 自动递增
sequence
native 最常用 自动递增
uuid 生成一个全球唯一ID
使用Annotation
@GenerateValue 生成策略默认相当于native
@GenerateValue (strategy=GenerationType.IDENTITY) 指定策略
联合主键
@Embeddable 主键类
@EmbeddableId
@IdClass(value=xx.class)
eg:
@IdClass(studentPK.class)
public class student{
private int id;
private String name;
@Id
public int getId(){...}
@Id
public String getName{...}
}
0 0
- hibernate annotation&ID生成策略
- hibernate id 生成策略 annotation @GeneratedValue
- hibernate id 生成策略 annotation @GeneratedValue
- hibernate的ID生成策略(annotation方式@GeneratedValue)
- hibernate的ID生成策略(annotation方式@GeneratedValue)
- 【hibernate框架】用Annotation注解表示id生成策略
- Hibernate中的ID生成策略(XML和Annotation)
- Hibernate ID 生成策略
- hibernate id 生成策略
- hibernate ID生成策略
- Hibernate ID 生成策略
- Hibernate id生成策略
- hibernate---ID生成策略
- hibernate id生成策略
- hibernate id 生成策略
- hibernate--ID生成策略
- Hibernate 通过annotation 生成ID
- hibernate annotation主键生成策略
- hibernate 对象的三种状态
- 加密聊天解决方案——木星文
- hibernate update
- hibernate 核心开发接口
- matlab 读写txt文件
- hibernate annotation&ID生成策略
- struts2 一般开发流程
- struts2 标签
- struts2 OGNL表达式
- struts2 valuestack
- 属性2
- HDU 5007-Post Robot(字符串)
- 图形学中的贴图采样、走样与反走样等
- 海康ps流转换h264流