0
は、私は1つの外部キー ComponentMarksクラスを持つことになり、複合主キーに作成する必要があります:複合主キーは、TopLink
public class ConsolidatedMarks {
@Id
private String submission_unique_ID;
/****************getters and setter************/
}
エラー:
Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [RDEVAL_MySQL_DB] failed.
Internal Exception: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [com.eta.entityBeans.SubQuesCompIDs] and those of the entity bean class [class com.eta.entityBeans.ComponentMarks] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
java.lang.Exception:
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader
context: /ProjectName **
delegate: false
----------> Parent Classloader:
[email protected]
Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [RDEVAL_MySQL_DB] failed.
Internal Exception: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [com.eta.entityBeans.SubQuesCompIDs] and those of the entity bean class [class com.eta.entityBeans.ComponentMarks] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
も "@IdClass(SubQuesCompIDs.class)" でのJavaクラス "ComponentMarks" で、それはこのコンパイル・エラー・メッセージを示していた:
The attribute matching the ID class attribute consolidatedMarks does not have the correct type com.eta.entityBeans.ConsolidatedMarks
ConsolidatedMarksは、パッケージcom.eta.entityBeansからです。
更新ComponentMarks:
@Entity
@Table(name="component_marks")
@IdClass(SubQuesCompIDs.class)
public class ComponentMarks {
@Id
private String component_ID;
@Id
private String question_ID;
@Id
@Column(name="submission_unique_ID")
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="submission_unique_ID")
private ConsolidatedMarks consolidatedMarks;
/****************getters and setter************/
}
更新SubQuesCompIDs:
public class SubQuesCompIDs implements Serializable{
private String consolidatedMarks;
private String component_ID;
private String question_ID;
/****************getters and setter************/
}
今、コンパイルエラーで、2番目のエラーが来ていません。
ありがとうございます。私はコードを変更しましたが、私は同じエラーが発生しました。 ' 'コンポジットの主キーの指定が無効です。主キーのクラス[com.eta.entityBeans.SubQuesCompIDs]の主キーのフィールドまたはプロパティの名前と、エンティティBeanクラス[クラスcom.eta.entityBeans.ComponentMarks]の対応する必要があり、それらの型が同じである必要がありますまた、XMLの対応する属性および/または対応するフィールドの@Idにid要素を指定していることを確認してくださいまたはエンティティクラスのプロパティ " –
私はテーブル作成コードも追加しています。 CREATE TABLEを 'component_marks'( \t' submission_unique_ID' VARCHAR(50)NOT NULL、 \t 'component_ID' VARCHAR(30)NULL NOT、 \t' question_ID' VARCHAR(30)NOT NULL)。 –
エラーを引き起こしているのかどうかはわかりませんが、フィールド 'consolidatedMarks'に '@Column(name =" submission_unique_ID ")という注釈を付けるべきではありません。 –