我想在 JPQL 中创建一个命名查询,但我不明白它是如何工作的......
这是我的实体:
@Entity
@NamedQueries({
@NamedQuery(name = "Translation.lang",
query = "SELECT t FROM Translation t WHERE t.reference.id = :refId AND t.language.lang = :lang")
})
@Table(name = "T_E_TRANSLATION_TRL")
public class Translation implements java.io.Serializable {
@Id
@Column(name = "TRL_ID", unique = true, nullable = false)
@TableGenerator(name="translationSeqStore",
table="T_S_APP_SEQ_STORE_AST",
pkColumnName="AST_SEQ_NAME",
valueColumnName = "AST_SEQ_VALUE",
pkColumnValue = "T_E_TRANSLATION_TRL.TRL_ID",
allocationSize=1)
@GeneratedValue(strategy=GenerationType.TABLE,
generator="translationSeqStore")
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TRL_REF_ID", nullable = false)
private Reference reference;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TRL_LAN_ID", nullable = false)
private Language language;
@Column(name = "TRL_LABEL", nullable = false, length = 4000)
private String label;
我应该在参考和语言上使用 LEFT JOIN 来选择这些 id 的翻译吗?
谢谢你。