• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

relational annotations for kin-referencing

 
Rob Shepherd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I'm attempting to convert my java objects into entity beans. I'm using seam and annotations.

I'm having trouble working out the correct way to apply relations.

My object



These link my objects together. Some are connected to others. a MyObject instance can only be connected to one other MyObject. But working the other way..... a MyObject can have multiple MyObjects connected to it.



so in the example above.

myobject1.getConnected() === null;
myobject2.getConnected() === myobject1;
myobject3.getConnected() === myobject1;

Nevertheless, i don't know what annotations to include in order to persist these objects.

do i use OneToMany? I thibk I have all the information for this.

Do I need to use ManyToOne in addition, In order to express the bi-directionality of the relationship? (even though i'm not too concerned with it)

If so, I would need to have another MyObject reference. Or wouldn't I.

confused.

help requested.

many thanks

Rob

[ October 02, 2007: Message edited by: Rob Shepherd ]
[ October 02, 2007: Message edited by: Rob Shepherd ]
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can map a many-to-one relationship between two different classes, do so, and then replace all references to Class2 with Class1
This is a many-to-one relationship, and you can keep it unidirectional for simplicity if you prefer so.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic