openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <cob...@windstream.net>
Subject Learning relationships - dazed and confused
Date Tue, 18 Nov 2008 04:15:50 GMT
Hello all,

I am trying to teach myself OpenJPA.  I've done a bit of database relationships but I'm confused
while trying to set up entity relationships for a particular situation.  I'm hoping someone
will be kind enough to point me in the right direction.

Here's my scenario:
I have two tables: UserInfo and UserProperties
Each UserInfo will have a collection of UserProperties

I'm trying to define UserInfo as:
@Entity
@Table(name="UserInfo")
public class UserInfo implements Serializable {
....
@Id
private Long id;

@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
@JoinColumn(name="prop_id", referencedColumnName="userId")
private Collection<UserProperties> userProperties;

<etc>

And I have UserProperties defined like:
@Entity
@Table(name="userproperties")
public class UserProperties implements Serializable {

@Id
private Integer id;
	
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="user_id", referencedColumnName="id")
private Integer userId;

But I get errors while trying to deploy:
<openjpa-1.0.2-r420667:627158 fatal user error> org.apache.openjpa.util.MetaDataException:
The type of field "com.whitetail.sawhorse.data.UserProperties.userId" isn't supported by declared
persistence strategy "OneToOne".  Please choose a different strategy.

I'm not sure how to set up the join type in UserProperties.  Basically, I will have many UserInfo
entities, each with a collection of UserProperties.  The UserProperties will be joined to
a single UserInfo; primarily because each UserInfo can have an arbitrary set of UserProperties.

Is this possible?  If so, can anyone offer any suggestions on how to set it up?

I'm basically lost at this point.

Thanks in advance!
Randy

Mime
View raw message