使用 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")
}),//五级延伸
……}