openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <cob...@windstream.net>
Subject Mapping a collection of entities...
Date Wed, 19 Nov 2008 01:36:39 GMT
Hello all,

I'm trying to teach myself OpenJPA and failing miserably...  I have two entities (code below)
where one contains a collection of the other.  The intent is for UserInfo to be able to contain
a collection (or List) of an arbitrary number of UserProperties.  The UserProperties are defined
at run-time by data entered through the application.

With it defined as follows in the ear file deploys fine in Geronimo, but calling any of the
service methods that try to query or insert data result in the following errors:
javax.ejb.EJBException: The bean encountered a non-application exception.; nested exception
is: 
	<openjpa-1.0.2-r420667:627158 fatal user error> org.apache.openjpa.persistence.ArgumentException:
You have supplied columns for "com.whitetail.sawhorse.data.UserInfo.userProperties", but this
mapping cannot have columns in this context.

The relevant portion of the entities are defined as:
@Entity
@Table(name="userinfo")
public class UserInfo implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id", nullable=false, insertable=false, updatable=false)
	private Integer id;
	
	@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
	@JoinColumn(name="prop_id", referencedColumnName="userId")
	private Collection<UserProperties> userProperties;
	
and

@Entity
@Table(name="userproperties")
public class UserProperties implements Serializable {

	@Id
	@Column(name="id", nullable=false)
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="user_id", referencedColumnName="id")
	private UserInfo userInfo;
	
I thought I had it right according to the documentation and the few examples I've seen, but
I've got something wrong.  Any help getting this solved would be greatly appreciated.

Cheers!
Randy

Mime
View raw message