`
geeksun
  • 浏览: 953714 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

annotation for hibernate

 
阅读更多

@Controller控制器

@Service 
@Conponent  组件
@Repository  Dao访问层
@Entity 实体
@Table 实体mapping表
@Column 属性mapping列   ---->  不需要Mapping的时候用@Transient
@Id mapping主键属性,可以将Entity中的某个属性标识为标识符(identifier)。可通过应用自身创建,也可以由Hibernate生成。
@Genarated value 标识符的生产策略。

*AUTO        可以是一下三种任意一种类型,取决于底层数据库的不同

*TABLE       使用table保存id

*IDENTITY    identity column 主键由数据库自动生成(主要是自动增长型,像MySql、SQL Server)

 *SEQUENCE   sequence (Oracle主键不能自增长,使用Sequence)

 

@Id
@GeneratedValue(strategy = GenerationType.IDENTITy)
 
Public Integer getId() {… …}
@Id 
@GeneratedValue(generator = "system-uuid")[该属性名自定义]
@GenericGenerator(name = " system-uuid ", strategy = "uuid")
[name可自定义,但是strategy属性必须是Hibernate中有效的主键策略]
@Column (name = "user_id")
private Integer userId;
 
@Id 
@GeneratedValue(generator = "hilo")
@GenericGenerator(name = "hilo", strategy = "hilo")
@Column (name = "user_id")
private Integer userId;
 
@mappedBy用法
mappedBy用于OneToMany、ManyToMany、OneToOne,指由另一方维护两者的关系。

注解分为两类,分别是Logical mapping和Physical mapping,通过Logical mapping可用描述对象模型,类之间的关系等等,而Physical mapping注释则描述了物理的schema,表,列,索引等等。

 

分享到:
评论

相关推荐

    Hibernate+中文文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...

    hibernate3.2中文文档(chm格式)

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...

    HibernateAPI中文版.chm

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...

    Hibernate中文详细学习文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...

    Hibernate 中文 html 帮助文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...

    最全Hibernate 参考文档

    5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...

    hibernate 体系结构与配置 参考文档(html)

    使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...

    Hibernate注释大全收藏

    Hibernate注释大全收藏 声明实体Bean @Entity public class Flight implements Serializable { Long id; @Id public Long getId() { return id; } public void setId(Long id) { this.id = id; } } @Entity ...

    Hibernate教程

    6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...

    Hibernate_3.2.0_符合Java习惯的关系数据库持久化

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent ...

    hibernate3.04中文文档.chm

    6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...

    Hibernate3+中文参考文档

    5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...

    hibernate 框架详解

    使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. 集合...

    Hibernate参考文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...

    Aspectj in Action: Enterprise AOP with Spring Applications (2nd Edition)

    You'll master key features including annotation-based syntax, load-time weaver, annotation-based crosscutting, and Spring-AspectJ integration. Building on familiar technologies such as JDBC, ...

    ssh框架搭建实例源码

    本资源是一个最简单的一个ssh框架实例,包含完整的代码(dao层有annotation和xml两种实现方式修改applicationContext.xml和hibernate.cfg.xml相应位置就可以切换),数据库ssh.sql文件,和所有的jar包,运行于eclips...

    Portlets in action

    PART 2 DEVELOPING PORTLETS USING SPRING AND HIBERNATE Getting started with Spring Portlet MVC Annotation-driven development with Spring Integrating portlets with databases PART 3 ADVANCED PORTLET ...

    HibernateValidatorJSR303的参考实现使用指南.pdf

    8.5. Boolean composition for constraint composition 9. Annotation Processor 9.1. 前提条件 9.2. 特性 9.3. 配置项 9.4. 使用标注处理器 9.4.1. 命令行编译 9.4.2. IDE集成 9.5. 已知问题 10. 进一步阅读

    springframework.5.0.12.RELEASE

    Exporting a lazily initialized bean (which implements SelfNaming and is annotated with ManagedResource annotation) gives IllegalStateException [SPR-17592] #22124 MockHttpServletRequest changes Accept-...

    Google Guice: Agile Lightweight Dependency Injection Framework

    * Learn simple annotation-driven dependency injection, scoping and AOP, and why it all works the way it works. * Be the first to familiarize yourself with concepts that are likely to be included in ...

Global site tag (gtag.js) - Google Analytics