`
lucene3212
  • 浏览: 133700 次
  • 性别: Icon_minigender_2
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

JPA注解配置实例

阅读更多

    以下收集了一些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;   
    }   
}  

?

 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics