-->
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: How to annotate OneToOne for a non persistent entity
PostPosted: Wed Jan 03, 2007 4:32 pm 
Beginner
Beginner

Joined: Thu Nov 16, 2006 11:34 am
Posts: 26
Location: Boston
I have two classes A, B. A has a uni directional one-one with B. A has 5 properties is mapped to a table TableA B has 3 properties mapped to TableA again So B doesnt really have another table but its the same table
Now in hibernate, how do I give the one-one mapping of A->B
as B doesnt have a primary key of its own

(B doesnt extend A and should not as in my domain model, B is like a common class which many other domain classes have a one-one relationship.

If someone could help me with 3.1 annotations as to how I should annotate the getClassB() in A and the classB domain objects it would be great!


Hibernate version: 3.1

Name and version of the database you are using: Oracle 9i


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 6:04 pm 
Newbie

Joined: Wed Aug 03, 2005 2:13 am
Posts: 16
It sounds like a component mapping might be what you're looking for, have you seen this before? http://www.hibernate.org/hib_docs/v3/reference/en/html/components.html

However, if B is a common class with properties that many other tables have, then maybe it would make sense for B to be a base class that these others extend from?

ie- in many apps I've worked on, we have a "BaseEntity" that contains auditing columns, version columns, ID column, etc, and most others extend from it.


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.