-->
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.  [ 4 posts ] 
Author Message
 Post subject: the association between a session and object
PostPosted: Wed Dec 29, 2004 10:39 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
The scenario:

List tasks = session.find("bla bla bla");
Task t = tasks.get(0);
if (SOMETHING) {
t.setStatus("Changed");
}

HERE I WANT TO UPDATE task by
Calling update(task) causes that Exception the object was already associated with the session....
OR
Calling session.flush() that does nothing

How can I do the update in the same session;
- by breaking the association between session and obj, if so how?
- by dynamic updates, I remember that calling set methods of associated objects dynamically generates update sql's, but somehow I did block this property and I dont remember exactly what can block it.

Thanks

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just change your objects, there is no need to call update() for objects still within session scope.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 10:56 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
I do, but it doesnt still generates update sql's
Somehow I did block it, but I dont know how. How can I enable it?

I used session.clear() before update.
What are the drawbacks of using session.clear in each update?

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 11:05 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
michael wrote:
Just change your objects, there is no need to call update() for objects still within session scope.


Hibernate is running in the server and object modification is in the client side
And when the client changes a object, I do not send a request for the server that can be the reason why changes should not be detected by the session.

I think I can handle it like;

Client : request to server : give me the tasks

Client changes some attributes of task

Send another request to the server : update

Server gets request and calls session.clear() session.update(request parameter)

That is why I think I should use clear and update each time.
But calling clear before each update makes me to feel uncomfortible about the performance.
I wanted to know the drawbacks of session.clear exactly.
What about session.evict(Object) ? Is this removes the object from the session?

_________________
-developer


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