openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ericp56 <eric.phettepl...@twcable.com>
Subject PK Problem, mismatched property
Date Tue, 09 Sep 2008 16:56:26 GMT

I have three tables:
Question
id long (PK)
description string
etc.
Survey
id long (PK)
surveydate Date
etc.
QuestionResults
SurveyResultsID (FK)
QuestionID (FK)
Answer

Here's my class that won't persist, because of errors (to follow):

@Entity
@Table(name="QuestionResults")
@IdClass(QuestionResultsPK.class)
public class QuestionResults implements Serializable {

	private int answer;

	@Id
	@ManyToOne
	@JoinColumn(name="QuestionID")
	private QuestionProp questionid;

	@Id
	@ManyToOne
	@JoinColumn(name="SurveyResultsID")
	private SurveyResults surveyresultsid;
...

Here's the PK class:

@Embeddable
public class QuestionResultsPK implements Serializable {

	@Column(name="SurveyResultsID", insertable=false, updatable=false)
	private SurveyResults surveyresultsid;

	@Column(name="QuestionID", insertable=false, updatable=false)
	private QuestionProp questionid;
...

Here's the error raised:
12:33:02,703 ERROR [Survey] Exception in WriteQuestionResult
12:33:02,703 ERROR [Survey] <openjpa-1.2.0-r422266:683325 fatal user error>
org.apache.openjpa.persistence.ArgumentException: The id class specified by
type "class com.abc.ivr.survey.QuestionResults" does not match the primary
key fields of the class.  Make sure your identity class has the same primary
keys as your persistent type, including pk field types. Mismatched property:
"questionid"
	at
org.apache.openjpa.meta.ClassMetaData.validateAppIdClassPKs(ClassMetaData.java:1983)
	at
org.apache.openjpa.meta.ClassMetaData.validateAppIdClass(ClassMetaData.java:1897)

I ported this code from a Swing/Tomcat application, but I was using OpenJPA
1.1.  Now I am using OpenJPA 1.2 on Geronimo (a 2.1.4 build)

Any suggestions?

Thanks,

Eric
-- 
View this message in context: http://n2.nabble.com/PK-Problem%2C-mismatched-property-tp1078084p1078084.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message