0
두 개의 테이블이 있으며 첫 번째 부분은 다른 테이블의 기본 키이기도 한 두 개의 기본 복합 키가 있습니다.복합 기본 키의 일부인 외래 키
CustomerOfferAcceptance
는 // primary key part 1 also a fk
이 // primary key part 2
제공
ID를 CUSTOMER_ID OFFER_ID 내가 OFFER_ID 및 ID에이 두 테이블을 조인 할 수 있도록하고 싶습니다 // primary key
. 에서 오
선택이 쿼리를 구문 분석 할 때
이
@Entity
@Table(name = "customer_offer_acceptance", schema = "rz_customer")
public class CustomerOfferAcceptance {
@EmbeddedId
private CustomerOfferPK key;
@MapsId("offerId")
@ManyToOne
@JoinColumn(name="offer_id", referencedColumnName = "id")
private Offer offer;
}
@Embeddable
public class CustomerOfferPK implements Serializable {
private static final long serialVersionUID = -8847738316352487377L;
@Column(name = "customer_id")
private String customerId;
@Column(name = "offer_id")
private String offerId;
public CustomerOfferPK() { }
public CustomerOfferPK(String customerId, String offerId) {
super();
this.customerId = customerId;
this.offerId = offerId;
}
}
@Entity
@Table(name = "offer", schema = "rz_customer")
public class Offer implements Serializable{
private static final long serialVersionUID = -7842210981812803506L;
@Id
@Column(name="id")
private String id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "offer")
private Collection<CustomerOfferAcceptance> CustomerOfferAcceptance;
}
나는 예외가 코드 내가 한 persistence.domain.CustomerOfferAcceptance COA 내부는 O를 persistence.domain.Offer에 참여할 경우 coa.customer_id =
을 someId 예외 :
Caused by: java.lang.IllegalStateException: DOT node with no left-hand-side!
at org.hibernate.hql.internal.ast.tree.DotNode.getLhs(DotNode.java:667)
at org.hibernate.hql.internal.ast.tree.DotNode.getDataType(DotNode.java:644)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:389)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3858)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3644)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3522)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1796)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
목 많이 anks!