我的供應商是: org.eclipse.persistence.jpa.PersistenceProviderJPA的FetchType.LAZY不起作用?
我的實體代碼:
@Entity
@NamedQueries({ @NamedQuery(name = "Bank.findAll", query = "select o from Bank o") })
@Table(name = "B_BANK")
public class Bank implements Serializable {
private final static String ID_GENERATOR = "Bank";
private Long id;
private User modifier;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ID_GENERATOR)
@SequenceGenerator(name = ID_GENERATOR, allocationSize = 1, sequenceName = "sq_B_BANK")
@Column(name = "id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modifier")
public User getModifier() {
return modifier;
}
public void setModifier(User modifier) {
this.modifier = modifier;
}
}
而且我的測試代碼只是:
entityManagerHelper = new EntityManagerHelper("Model", isAutoCommit);
List l = entityManagerHelper.getEntityManager().createQuery("select b from Bank b").getResultList();
但是在我的控制檯中我有這個:
SELECT標識,改性劑FROM B_BANK SELECT標識,CREATION_DATE,MODIFICATION_DATE,改性劑,創建者FROM B_USER WHERE(ID =?) 綁定=> [2]
因此似乎JPA用於查詢我把用戶fetch = FetchType.LAZY! 我想知道爲什麼JPA會爲用戶查詢。 任何幫助,將不勝感激。
謝謝克里斯 – 2013-05-07 03:56:01
+ 1很酷,不知道 – kostja 2013-05-07 05:55:33