本帖最后由 SOAR 于 2013-5-15 09:21 编辑
我要映射这样一个实体。
public class Person {
private int id;
private String name;
private String resume;//简历
private byte[] photo;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(length=10,nullable=false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Lob
@Basic(fetch=FetchType.LAZY)
public void getResume(String resume) {
this.resume = resume;
}
public void setResume(String resume) {
this.resume = resume;
}
@Lob
@Basic(fetch=FetchType.LAZY)
public byte[] getPhoto() {
return photo;
}
public void setPhoto(byte[] photo) {
this.photo = photo;
}
}
然后写了一个测试方法
public void testAdd(){
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Person p = em.find(Person.class, 1);
em.getTransaction().commit();
em.close();
emf.close();
}
我把person中的resume和photo的加载方式都设的是lazy,为什么后台log4j打印出的信息是
:DEBUG SQL:104 - select person0_.id as id1_0_0_, person0_.name as name1_0_0_, person0_.photo as photo1_0_0_, person0_.resume as resume1_0_0_, from Person person0_ where person0_.id=?
按理说现在它不该查询resume和photo啊?
|