-->
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: Session.lock(object, LockMode.READ) prints annoying StackTra
PostPosted: Mon Jan 12, 2004 12:43 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Calling Session.lock(object, LockMode.READ) on a stale object prints an annoying StackTrace before throwing a StaleObjectStateException.

According to the API specs, this exception is expected so I believe Hibernate shouldn't print any stack trace when such event occurs.

We are using the Session.lock() to detect changes and invalidate our cached data. In this case, the exception is nothing that can occur and the stack trace in the logs is not meaningfull.

Does someone have a workaround for this ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 1:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I find that to believe since hibernate don't do ex.printstacktrace() anywhere in the core.

Please show the file and linenumber in hibernate that should do this ? (you got the source ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 4:26 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Hibernate doesn't print the stacktrace itself, but a call to the LOG api does ;-)

Here is the guilty code fragment (StaleObjectStateException constructor):

Code:
public StaleObjectStateException(Class persistentClass, Serializable identifier) {
      super("Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)");
      this.persistentClass = persistentClass;
      this.identifier = identifier;
      LogFactory.getLog(StaleObjectStateException.class).error("An operation failed due to stale data", this);
   }


BTW: I don't think it is good practice to call the LogFactory like this inside the Exception constructor itself...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 4:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmmm...i agree it ain't beautifull....but it sure is nice to have it there in most circumstances....but i'll suggest you submit a request to the JIRA and explain why you don't like it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 5:33 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-624 has been created for this issue.


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.