-->
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.  [ 5 posts ] 
Author Message
 Post subject: Creating multiple objects but one table
PostPosted: Sun Nov 07, 2004 4:26 pm 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
Can I create two different mappings to the same database table.

For example (we have a legacy system), I have a table with 100 columns. I want two different objects to represent different columns in the database.

I've read http://www.hibernate.org/41.html but it seems not a intuitive way to handle this (I don't want inheritance). I'm using 2.1.6. Will future versions (e.g Hibernate 3) handle this better?

Dino


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can have different mapping on the same table as long as you only load 1 row at the same time in the session.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 8:17 pm 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
Why is the cached object based on the table name and not on the class name?

Dino


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 8:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is no cahced object.
Think in a different way.
What if you have 2 instances representing the same row (and possibly the same column). Which one Hibernate will chose to win the race when you update both ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 6:26 pm 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
I understand your response but it was a technique I used with TopLink. I basically had two or three type of objects (CoreInformation, DetailedInformation). I never liked lazy loading since if I had many one to ones then it would become inefficient to retrieve data.

In the the scenerio you described it would never happen since I wouldn't have overlap columns.

Even if I did have overlap columns, then I would evict from the cache the other representation so the next time it is retrieve it will grab the value from the database (I would never update both representation within the same session). Ibatis can do this as well via configuration.

Thanks

Dino


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