六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 5|回复: 0

JPA注解配置实例

[复制链接]

升级  94%

320

主题

320

主题

320

主题

进士

Rank: 4

积分
970
 楼主| 发表于 2013-2-3 10:47:55 | 显示全部楼层 |阅读模式
以下收集了一些JPA常用的注解实例:

@Entity  @Table(name="ACCOUNT_INFO")   public class ManagerAccountInfo implements Serializable {       private static final long serialVersionUID = -1021341410178291401L;              private Long id;       private String loginAccount;       private Date lastLoginDate;       private ManagerOperator managerOperator;       private Set<FrameworkAccountLevel> frameworkAccountLevels;       private String officeNo;              //标识字段       @Id      @GeneratedValue(generator = "Cjm-Generator")       @GenericGenerator(name = "Cjm-Generator", strategy = "com.cjm.core.utils.IdGenerator")       @Column(name="id")       public Long getId() {           return id;       }       public void setId(Long id) {           this.id = id;       }              //普通字段       @Column(name = "LOGIN_ACCOUNT")       public String getLoginAccount() {           return this.loginAccount;       }      public void setLoginAccount(String loginAccount) {           this.loginAccount = loginAccount;      }        //日期字段      @Temporal(TemporalType.DATE)       @Column(name = "LAST_LOGIN_DATE")       public Date getLastLoginDate() {           return this.lastLoginDate;       }       public void setLastLoginDate(Date lastLoginDate) {          this.lastLoginDate = lastLoginDate;       }        //多对一      @ManyToOne(fetch = FetchType.LAZY)      @JoinColumn(name = "MO_ID",   referencedColumnName = "MO_ID")      public ManagerOperator getManagerOperator() {          return this.managerOperator;       }       public void setManagerOperator(ManagerOperator managerOperator) {           this.managerOperator = managerOperator;      }        //一对多      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "managerAccountInfo")      public Set<FrameworkAccountLevel> getFrameworkAccountLevels() {           return this.frameworkAccountLevels;      }     public void setFrameworkAccountLevels(              Set<FrameworkAccountLevel> frameworkAccountLevels) {          this.frameworkAccountLevels = frameworkAccountLevels;      }        //非持久化字段       @Transient      public String getOfficeNo() {           return officeNo;       }      public void setOfficeNo(String officeNo) {           this.officeNo = officeNo;       }   }  
?
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表