-->
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.  [ 8 posts ] 
Author Message
 Post subject: Object updates
PostPosted: Wed Nov 02, 2005 6:08 am 
Newbie

Joined: Fri Oct 28, 2005 7:35 am
Posts: 12
Hibernate version: 3

We are looking to convert an existing Application to Java and are looking to use Hibernate as the persistency layer. This application is a thick client app and will be based on J2SE. The application is BIG with large numbers of domain objects.

If I understand correctly, Hibernate takes a copy of an objects contents when it is read from the session. It then uses this information to determine of an object has changed when the session is flushed. We are worried that in our application this could a) take up a large amount of memory and b) cause performance problems when a flush occurs. If a thousand objects are read and only one is updated, Hibernate will check all objects for changes - this could take some time. Is it possible to configure that behaviour so that objects are not copied on load, but when say session.update(anObject) is executed ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 4:17 am 
Newbie

Joined: Fri Oct 28, 2005 7:35 am
Posts: 12
Could someone please help me with this request ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 4:26 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

your concerns may be right.
When using the session cache you should have a
concept of "unit of work". Perhaps you can read:

http://www.hibernate.org/42.html

The easiest way is to write a small
test application.
Controlling the session cache can be done
in several ways like session.clear or evict.
Or using the stateless session.

Hope this helps a bit.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 5:11 am 
Newbie

Joined: Fri Oct 28, 2005 7:35 am
Posts: 12
Hi,
Thanks for the help. I have taken a look at StatelessSession, but unforchinatly this session does not handle proxies or collections !!!!
Anyother ideas ?
I have a test application that I am using.
Regards
Ian


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 6:09 am 
Newbie

Joined: Fri Oct 28, 2005 7:35 am
Posts: 12
I want to utialize the session cache, I just do not want the session to think that every object that is being read "could" be updated.

Is there a way to work with two sessions, say a readonly session for handling the main work of the application, and a second session, where objects could be "updated" in and could be used to control object changes ?

Is it possible to configure a session to be readonly ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 3:30 am 
Newbie

Joined: Fri Oct 28, 2005 7:35 am
Posts: 12
I have been able to create a read only session by creating a second set of mapping files, each one having mutable="false" within the class definitions.

I then create two sessions, one on the read only mapping and one on the read/write mappings. I then read the objects form the read only session. I get caching, but no "deepCopy" is created. I then "update" the object in the second (read/write) session and then modify it. When I flush the read/write session, the object is updated in the DB... GREAT.

However I have a few questions.
1) Creating two sets of mapping files means I have LOTS of mapping files to maintain. Also using two sets also means that the start up time of Hibernate is almost doubled. Is it possible to just use just one set ?

2) Is this a "good" use og hibernate ? Am I just forcing hibernate to do something it really does not want to do ?

3) Is there a better way of creating a read only session ?

Thanks
Ian


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 4:00 am 
Newbie

Joined: Thu Jun 23, 2005 9:23 pm
Posts: 13
imeikle wrote:

However I have a few questions.
1) Creating two sets of mapping files means I have LOTS of mapping files to maintain. Also using two sets also means that the start up time of Hibernate is almost doubled. Is it possible to just use just one set ?

2) Is this a "good" use og hibernate ? Am I just forcing hibernate to do something it really does not want to do ?

3) Is there a better way of creating a read only session ?


i just try answering your first questions based on my kowleage of hibernate.
hope a bit help for you .:)
1)you can use just one set of mapping files.likes below:
<class name="cim.core.Naming" table="NAMING" >
<id>...........</id>
<property >......</property>
<class>
<class name="cim.core.BaseVoltage" dynamic-update="true" table="BASEVOLTAGE">
<id>...........</id>
<property >......</property>
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 4:07 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
imeikle wrote:
I have been able to create a read only session by creating a second set of mapping files, each one having mutable="false" within the class definitions.


that's a lot of code ... why don't you keep the same SINGLE set of mapping files and do the following:

1.) build Configuration
2.) build sesionFactory 1
3.) loop through Configuration.getCLassMappings().getProperties() , setting all properties to non-mutable

or ...

transform the same set of mapping files with a little XSLT.

4.) build sessionFactory 2


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