Note that there are some explanatory texts on larger screens.

plurals
  1. POhibernate creates problem for table with composite primary key while generating hibernate classes with eclipse
    text
    copied!<p>I have 2 tables as given below.</p> <hr> <h2>feedback_answer</h2> <p>question_id number(primary key)</p> <p>answer_id number (primary key)</p> <p>answer_en varchar2(255)</p> <p>answer_it varchar2(255)</p> <hr> <h2>user_feedback</h2> <p>verification_id number(primary key)</p> <p>question_id number(foreign key - feedback_answer)</p> <p>answer_id number(foreign key - feedback_answer)</p> <hr> <p>I am getting following error for hibernate after hibernate class generation in eclipse</p> <p><strong>ERROR :: 2009-12-29 14:57:34,093 ERROR java.lang.Class (http-8080-2) - Initial SessionFactory creation failed.org.hibernate.MappingException: Foreign key (FK39E53D791A62BD16:USER_FEEDBACK [QUESTION_ID])) must have same number of columns as the referenced primary key (FEEDBACK_ANSWER [QUESTION_ID,ANSWER_ID])</strong></p> <p>Following is the java code for feedback_answer</p> <pre><code>public class FeedbackAnswer implements java.io.Serializable { private FeedbackAnswerId id; private FeedbackQuestion feedbackQuestion; private String answerEn; private String answerIt; private Set&lt;Verification&gt; verifications = new HashSet&lt;Verification&gt;(0); public FeedbackAnswer() { } public FeedbackAnswer(FeedbackAnswerId id, FeedbackQuestion feedbackQuestion) { this.id = id; this.feedbackQuestion = feedbackQuestion; } public FeedbackAnswer(FeedbackAnswerId id, FeedbackQuestion feedbackQuestion, String answerEn, String answerIt, Set&lt;Verification&gt; verifications) { this.id = id; this.feedbackQuestion = feedbackQuestion; this.answerEn = answerEn; this.answerIt = answerIt; this.verifications = verifications; } public FeedbackAnswerId getId() { return this.id; } public void setId(FeedbackAnswerId id) { this.id = id; } public FeedbackQuestion getFeedbackQuestion() { return this.feedbackQuestion; } public void setFeedbackQuestion(FeedbackQuestion feedbackQuestion) { this.feedbackQuestion = feedbackQuestion; } public String getAnswerEn() { return this.answerEn; } public void setAnswerEn(String answerEn) { this.answerEn = answerEn; } public String getAnswerIt() { return this.answerIt; } public void setAnswerIt(String answerIt) { this.answerIt = answerIt; } public Set&lt;Verification&gt; getVerifications() { return this.verifications; } public void setVerifications(Set&lt;Verification&gt; verifications) { this.verifications = verifications; } </code></pre> <p>}</p> <p>Following is the hibernate code for feedback_answer</p> <pre><code>&lt;hibernate-mapping&gt; &lt;class name="com.certilogo.inspect.backend.FeedbackAnswer" table="FEEDBACK_ANSWER" schema="SCOTT"&gt; &lt;composite-id name="id" class="com.certilogo.inspect.backend.FeedbackAnswerId"&gt; &lt;key-property name="answerId" type="long"&gt; &lt;column name="ANSWER_ID" precision="22" scale="0" /&gt; &lt;/key-property&gt; &lt;key-property name="questionId" type="long"&gt; &lt;column name="QUESTION_ID" precision="22" scale="0" /&gt; &lt;/key-property&gt; &lt;/composite-id&gt; &lt;many-to-one name="feedbackQuestion" class="com.certilogo.inspect.backend.FeedbackQuestion" update="false" insert="false" fetch="select"&gt; &lt;column name="QUESTION_ID" precision="22" scale="0" not-null="true" /&gt; &lt;/many-to-one&gt; &lt;property name="answerEn" type="string"&gt; &lt;column name="ANSWER_EN" /&gt; &lt;/property&gt; &lt;property name="answerIt" type="string"&gt; &lt;column name="ANSWER_IT" /&gt; &lt;/property&gt; &lt;set name="verifications" inverse="true" table="USER_FEEDBACK"&gt; &lt;key&gt; &lt;column name="ANSWER_ID" precision="22" scale="0" /&gt; &lt;column name="QUESTION_ID" precision="22" scale="0" /&gt; &lt;/key&gt; &lt;many-to-many entity-name="com.certilogo.inspect.backend.Verification"&gt; &lt;column name="VERIFICATION_ID" precision="22" scale="0" not-null="true" unique="true" /&gt; &lt;/many-to-many&gt; &lt;/set&gt; &lt;/class&gt; </code></pre> <p></p> <p>Can anyone help me regarding the matter?</p> <p>Thanks.</p> <p>amar4kintu</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload