gpt4 book ai didi

java - 需要 JPA 内连接查询语法帮助

转载 作者:行者123 更新时间:2023-12-01 13:50:18 24 4
gpt4 key购买 nike

我想知道你们是否可以帮助我完成我正在尝试编写的 OpenJPA 查询。
我有一个 ItemEntity...

@Entity(name = "item")
public class ItemEntity implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "itemid")
@TableGenerator(name = "itemid", table = "items_sequence", allocationSize = 1)
private Long id;
@ManyToOne
private ImportPayloadEntity importPayloadEntity;

还有一个 ImportPayloadEntity...

@Entity(name = "import_payload")
public class ImportPayloadEntity implements java.io.Serializable{
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "importpayloadid")
@TableGenerator(name = "importpayloadid", table = "import_payload_sequence", allocationSize = 1)
private Long id;
@Column(name = "PROCESSED_IND")
private String processedInd;

我试图从我的项目实体中选择连接回我的导入有效负载实体,以确保processedInd 等于“N”。

我不太明白正确的语法。我尝试了一些方法,但这是我最新的尝试..

@NamedQuery(name = "queryItems", query = "SELECT c1, c2 FROM item c1 INNER JOIN c1.importPayloadEntity c2 WHERE c2.processedInd='N'")

这给了我...

Unknown column 't0.IMPORTPAYLOADENTITY_ID' in 'on clause' {prepstmnt 1719904819 SELECT t0.id, t1.id, t1.FILENAME, t1.LOAD_DATETIME, t1.IMPORT_PAYLOAD_BODY, t1.IMPORT_PAYLOAD_TYPE, t1.PROCESSED_DATETIME, t1.PROCESSED_IND FROM item t0 INNER JOIN import_payload t1 ON t0.IMPORTPAYLOADENTITY_ID = t1.id WHERE (t1.PROCESSED_IND = ?)} [code=1054, state=42S22]

感谢您的帮助。

最佳答案

您可以尝试从项目 i 中选择 i,其中 i.importPayloadEntity.processedInd = 'N'

关于java - 需要 JPA 内连接查询语法帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20015211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com