使用 JPA 多表关联注解 ManyToOne ,之类的写功能的时候,生成了这样一个 sql ,表别名是重复的,不知道为什么, 以下是片段,可以看出 tmpaymentsettlement 和 TMPAYMENTSETTLEMENTBILL 的别名是一样的,导致报错,不知道为什么,请大神解答
from tmpaymentsettlement tmpayments0_ left outer join TMPAYMENTSETTLEMENTBILL tmpayments0_ on tmpayments0_.ID=tmpayments0_.PAYMENTSETTLEMENTID left outer join TMPAYMENTSETTLEMENTDETAIL tmpayments1_ on tmpayments0_.ID=tmpayments1_.PAYMENTSETTLEMENTID left outer join TMPAYMENTSETTLEMENTTYPE tmpayments2_
附上部分表关系
@Table(name = "TMPAYMENTSETTLEMENT")
public class Tmpaymentsettlement implements Serializable {
XXX……
@OneToOne(mappedBy = "tmpaymentsettlement", orphanRemoval = true, fetch = FetchType.EAGER)
@NotFound(action= NotFoundAction.IGNORE)
@JSONField(name = "TMPAYTVERIFICATTIONREL")
private TmpaytverificattionrelC2 tmpaytverificattionrel;
@OneToOne(mappedBy = "tmpaymentsettlement", orphanRemoval = true, fetch = FetchType.EAGER)
@NotFound(action= NotFoundAction.IGNORE)
@JSONField(name = "BPSETTLEMENTANDRECEIPT")
private BpsettlementandreceiptC2 bpsettlementandreceipt;
@OneToMany(fetch = FetchType.EAGER)
@NotFound(action= NotFoundAction.IGNORE)
@JoinColumn(name = "PAYMENTSETTLEMENTID", referencedColumnName = "ID")
@JSONField(name = "TMPAYMENTSETTLEMENTDETAIL")
private Set<TmpaymentsettlementdetailC2> tmpaymentsettlementdetail;
@OneToMany(fetch = FetchType.EAGER)
@NotFound(action= NotFoundAction.IGNORE)
@JoinColumn(name = "PAYMENTSETTLEMENTID", referencedColumnName = "ID")
@JSONField(name = "TMPAYMENTSETTLEMENTTYPE")
private Set<TmpaymentsettlementtypeC2> tmpaymentsettlementtype;
@OneToMany(fetch = FetchType.EAGER)
@NotFound(action= NotFoundAction.IGNORE)
@JoinColumn(name = "PAYMENTSETTLEMENTID", referencedColumnName = "ID")
@JSONField(name = "TMPAYMENTSETTLEMENTBILL")
private Set<TmpaymentsettlementbillC2> tmpaymentsettlementbill;
}
@Table(name = "TMPAYMENTSETTLEMENTBILL")
这个表中没有关联 只有他本身的字段
@NamedEntityGraph(
……
@NamedSubgraph(name = "bpbizpaytreqpaytexectrecd", attributeNodes = @NamedAttributeNode(value ="tmjsxx", subgraph = "tmjsxx")),//四级延伸
@NamedSubgraph(name = "tmjsxx", attributeNodes = {
@NamedAttributeNode(value = "tmpaymentsettlement", subgraph = "tmpaymentsettlement"),
@NamedAttributeNode(value = "tmbillendorserequest", subgraph = "tmbillendorserequest"),
@NamedAttributeNode(value = "tmbillingrequest", subgraph = "tmbillingrequest"),
@NamedAttributeNode(value = "tmbillpayablerequest", subgraph = "tmbillpayablerequest")
}),//五级延伸
@NamedSubgraph(name = "tmpaymentsettlement", attributeNodes = {
@NamedAttributeNode(value = "tmpaytverificattionrel"),
@NamedAttributeNode(value = "bpsettlementandreceipt", subgraph = "bpsettlementandreceipt"),
@NamedAttributeNode(value = "tmpaymentsettlementdetail"),
@NamedAttributeNode(value = "tmpaymentsettlementtype"),
@NamedAttributeNode(value = "tmpaymentsettlementbill")
}),//五级延伸
……}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.