WEB开发网
开发学院软件开发Java jpa抓取策略详解fetch(lazy ,eager) 阅读

jpa抓取策略详解fetch(lazy ,eager)

 2009-09-26 00:00:00 来源:WEB开发网   
核心提示: 实体bean:autoJava代码packagecom.hibernate.jpa.bean1;importjavax.persistence.CascadeType;importjavax.persistence.Entity;importjavax.persistence.Generated

实体bean:auto

Java代码   

package com.hibernate.jpa.bean1; 
 
import javax.persistence.CascadeType; 
import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.Id; 
import javax.persistence.JoinColumn; 
import javax.persistence.ManyToOne; 
@Entity 
public class Auto { 
 
 /** 
 * one to many 一对多关联 
 */ 
 private Integer autoId; 
 private String autotype; 
 private String autonum; 
 private Garage garage; 
 
 @Id @GeneratedValue 
 public Integer getAutoId() { 
 return autoId; 
 } 
 public void setAutoId(Integer autoId) { 
 this.autoId = autoId; 
 } 
 public String getAutotype() { 
 return autotype; 
 } 
 public void setAutotype(String autotype) { 
 this.autotype = autotype; 
 } 
 public String getAutonum() { 
 return autonum; 
 } 
 public void setAutonum(String autonum) { 
 this.autonum = autonum; 
 } 
 @ManyToOne() 
 @JoinColumn(name="garageid") 
 public Garage getGarage() { 
 return garage; 
 } 
 public void setGarage(Garage garage) { 
 this.garage = garage; 
 } 
 
} 

Tags:jpa 抓取 策略

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接