-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Multiple Relationships to a Single Table
PostPosted: Fri Jun 29, 2007 4:26 pm 
Newbie

Joined: Mon Nov 13, 2006 4:45 pm
Posts: 5
I would like to map an object to (exactly) two instances of another object type. However, I receive this error:

Repeated column in mapping for entity: ProfileBean column: workspaceNodeId (should be mapped with insert="false" update="false")

Is it possible to map this type of relationship in Hibernate (JPA) without resorting to a Collection?

This specifically is what I would like to do:

I have a simple user profile object and a tree data structure built of nodes. The user profile needs handles to two nodes in that tree: The root node of the tree hierarchy and another arbitrary node in the tree (the home node). Here's the snippet of code.

...

public class ProfileBean implements Profile {

...

@ManyToOne(optional = true, fetch = FetchType.LAZY, targetEntity = WorkspaceNodeBean.class)
@JoinColumn(name = "workspaceNodeId")
private WorkspaceNode rootNode;

@ManyToOne(optional = true, fetch = FetchType.LAZY, targetEntity = WorkspaceNodeBean.class)
@JoinColumn(name = "workspaceNodeId")
private WorkspaceNode homeNode;

...

}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 4:31 pm 
Newbie

Joined: Mon Nov 13, 2006 4:45 pm
Posts: 5
As a follow-up:

The error disappears if the @JoinColumn annotations are removed. (They are unnecessary, because they refer to the target object's primary key field.) I have not actually tested that the code runs properly, but the environment starts cleanly.

Is this a bug (or limitation) of how @JoinColumn operates?

This is my configuration:
16:26:12,103 INFO [Version] Hibernate Annotations 3.3.0.GA
16:26:12,117 INFO [Environment] Hibernate 3.2.4.sp1
16:26:12,123 INFO [Environment] Bytecode provider name : cglib
16:26:12,221 INFO [Version] Hibernate EntityManager 3.3.1.GA


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.