-->
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 Entities mapped to same table
PostPosted: Thu Feb 03, 2011 4:24 am 
Newbie

Joined: Tue Jan 25, 2011 9:10 am
Posts: 1
Hi

I have a table with about 100 columns, but I frequently use about 10 of them. I have created two entities and mapped them to the same table as in the example below.

Code:
@Entity
@Table(name="mytable")
public class MyTable{
    ......
}

@Entity
@Table(name="mytable")
public class MyTableSummary{
    ......
}


MyTableSummary has only getter methods so that no changes can be made to the table using and object this class. Any updates to the table are made using MyTable entity.
I generally use the MyTableSummary entity in a list that displays all the entries in 'mytable'. This list is fetched using Criteria API.

When I add a new entry in the table or update an existing one using the MyTable entity, these changes are sometimes not reflected in the list of MyTableSummary entities immediately. If I fetch the list again after some time the changes are visible.

I also tried mapping MyTableSummary to a view that selects the 10 columns but sill I got the same issue.

Can anyone please help me understand why this is happening and how can I fix this issue.

Thanks
Amit Khanna


Top
 Profile  
 
 Post subject: Re: Multiple Entities mapped to same table
PostPosted: Thu Feb 03, 2011 3:12 pm 
Newbie

Joined: Fri Sep 28, 2007 7:40 pm
Posts: 9
These two entities will be assumed as separate entities by Hibernate.
1. Change in one entity will not reflect in other entity unless otherwise it is refreshed from the Database
2. If there are changes in first entity, Hibernate should have flushed the changes to DB(just save is not enough) and other entity should read the change from DB


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.