-->
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: Thread safety
PostPosted: Tue Jan 17, 2006 5:49 pm 
Newbie

Joined: Tue Jan 17, 2006 5:22 pm
Posts: 3
I'm attempting to convert my application to use hibernate instead of a home-grown half-assed solution.

My app acts as a server to users running a custom client. Each client connection is long-lived has its own thread.

Currently, users can cause the objects on the server to be modified and immediately written to the db. There isn't any synchronization control on this. When writing to the db, transactions are not being used.

Note: my app is the only process that opens the database, and all objects are read into memory during application initialization, and then flushed to db as changes are made.

All users need to see the SAME objects from their connections because these objects represent real physical objects that my application is controling, and that the users are cooperating with each other to manage.

My current main worry is if 2 threads modify a value on the same object (at the same time), will I get data corruption? (ie. obj.setName( newName ) )

I do see in the docs that a Session isn't thread safe, but I'm not sure where all the fancy footwork with hooking setXXX(newval) calls on objects to detect changes stop and Sessions begin.

-Trevor


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 5:55 pm 
Newbie

Joined: Tue Jan 17, 2006 5:22 pm
Posts: 3
I guess I should also mention that I'm thinking of using something like the scheme called "Long session with automatic versioning" from the Hib docs.

Basically, it shows it as:

Code:
session.reconnect();
foo.setProperty("bar");
session.flush();
sesssion.connection().commit();
session.disconnect();


But in my case, I'm hoping that I can modify my foo while the session is still disconnected, and then reconnect and flush:

Code:
foo.setProperty("bar");
....
session.reconnect();
session.flush();
sesssion.connection().commit();
session.disconnect();


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.