I have a situation where a Card entity has a foreign key to a Person.
我有这样一种情况,一个卡片实体有一个外国人的钥匙给一个人。
public class Card implements java.io.Serializable {
private String cardid;
private Person person;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="USERID")
public Person getPerson() {
return this.person;
}
}
The default fetch type for the person is LAZY. Can I specify the fetch type to EAGER within a query:
该人员的默认获取类型为LAZY。我可以在查询中指定快取类型吗:
QCard qCard = QCard.card;
JPQLQuery query = getQuery().from(qCard);
query.list(qCard);
Thanks for any help.
感谢任何帮助。
1 个解决方案
#1
14
Did you try
你试过
QCard qCard = QCard.card;
List<Card> cards = getQuery().from(qCard)
.innerJoin(qCard.person).fetch()
.list(qCard);
For QueryDSL 4.0.2+
QueryDSL 4.0.2 +
QCard qCard = QCard.card;
List<Card> cards = getQuery().from(qCard)
.innerJoin(qCard.person).fetchJoin()
.select(qCard).fetch();
#1
14
Did you try
你试过
QCard qCard = QCard.card;
List<Card> cards = getQuery().from(qCard)
.innerJoin(qCard.person).fetch()
.list(qCard);
For QueryDSL 4.0.2+
QueryDSL 4.0.2 +
QCard qCard = QCard.card;
List<Card> cards = getQuery().from(qCard)
.innerJoin(qCard.person).fetchJoin()
.select(qCard).fetch();