-->
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.  [ 9 posts ] 
Author Message
 Post subject: Hows does one map the fields of a class to different tables?
PostPosted: Fri Aug 06, 2004 5:22 pm 
Newbie

Joined: Fri Aug 06, 2004 5:16 pm
Posts: 7
Hibernate version: 2.1.5

Mapping documents: N/A

Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs: N/A

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

Debug level Hibernate log excerpt: N/A

My question is a "howto", not a runtime problem. I the property element of the hibernate
mapping document doesn't seem to have any way to specify a table different from the
one for the class the field is in. Is this possible?

Thanks,
Stan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 5:44 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 2:15 pm
Posts: 35
its a Class -> Table mapping

now, if yo have foreign keys, those can be mapped using many-to-one.

what exactly are you trying to do?

The following link fromt he documentation might help you:
http://www.hibernate.org/hib_docs/refer ... ppings-emp

hth,

_________________
--------------------------------------------------
To code or not to code... Is that a question?
--------------------------------------------------
Pritpal Dhaliwal


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 6:03 pm 
Newbie

Joined: Fri Aug 06, 2004 5:16 pm
Posts: 7
In addition to the usual Class -> Table mapping, two other ways of mapping a class are sometimes possible in an Object/Relational framework:

1) Mapping the fields of a table to multiple classes.

2) Mapping the fields of a class to multiple tables.

The canonical example of (1) is mapping the zip code field of an address
table to its own class to provide zipcode specific validation.

I really don't know why anyone would do (2), but the knucklehead who
came up with the schema we are using to evaluate Hibernate and JDO
did such a thing. You can perform the mapping in JDO with appropriate
vendor extensions.

It's not clear to me that it is possible in hibernate.

Thanks,
Stan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 6:06 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hibernate has of course excellent support for (1), check "Components" in the documentation. Now, (2) is non-sense marketing feature (OK, _sometimes_ you'd need it for an exotic legacy database mapping) and to stop the snakeoil salespeople, we will have it in Hibernate3.

If you like to confuse the poor sales weasel, ask him for a use case.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 6:15 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
By the way, this is a comprehensive and real world list of things you should compare:

http://blog.hibernate.org/cgi-bin/blosx ... tence.html

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 10:30 pm 
Newbie

Joined: Fri Aug 06, 2004 5:16 pm
Posts: 7
Thank you, Christian. I hope you don't mind if I quote you at the next meeting. I had to temper the tone of my increasingly wild rantings for personal survival. I suspect your opinion may hold more sway.

Bless you,
Stan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 11:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note that when Christian says "Hibernate3 will have...", he means Hibernate3 CVS already does have it.

And I agree, I have never, ever needed this feature, nor have any of the projects I've worked on or consulted on. This feature usually only comes up when people do checkbox feature list comparisons. (One of our philosophies is to implement the things that our users most need, rather than the things that look good in marketing literature.)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 5:29 pm 
Newbie

Joined: Wed Jul 28, 2004 3:20 pm
Posts: 16
I need this feature. Here's a real world example. I'm working with a legacy database that takes feeds from various vendors. The schema has been in place for many years and can't be changed. The datafeed I'm getting comes in XML format. I read the data into java objects using Castor. The object model is based on the XML format, not the database schema. So the java objects don't map nicely to the existing database schema....

Seems like a not highly unusal project, I'm suprised that you've never encountered something similar. I'm going to try to deal with it using components, but it's going to be ugly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 5:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
As already said in the thread, this is possible in H3


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.