-->
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.  [ 3 posts ] 
Author Message
 Post subject: >>>> onSave() not getting called, BUT record is
PostPosted: Wed Jan 19, 2005 12:12 pm 
Newbie

Joined: Thu Jan 13, 2005 6:30 pm
Posts: 12
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1

Mapping documents:

Code between sessionFactory.openSession() and session.close():

AddRecord.java
---------------------------------------------------
....
for (int j = 0 ; j < rList.size() ; j++) {
Record r = (Record) rList.get(j) ;
session.save(r);
}
...

Record.java
--------------------------------------------------
....
public class Record implements Interceptor {
...

public boolean onSave(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) throws CallbackException {

boolean result = false;

System.out.println(">>>>>>>>>>>>>>>onSave") ;
validateThis() ;

return result;
}
}
....

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


The problem is the record is getting SAVED in the database, but the onSave method defined in my persistent class above is not getting called. i also put debug/print statements in the other methods like onFlushDirty, preFlush, postFlush etc. none of them are getting called. BUT THE RECORD is SAVED in the database.

The Flush mode is AUTO and Dirty mode is false.

What am i missing?

when does the onSave get triggered? what can i do to make sure an onSave gets called when i invoke .save()?

thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 7:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Your domain classes should not implement Interceptor. An interceptor is something that is implemented by a seperate class and than "attached" to a session or session factory.

You can have your domain class implement the Lifecycle interface, but its use is discouraged.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 24, 2005 12:38 pm 
Newbie

Joined: Thu Jan 13, 2005 6:30 pm
Posts: 12
Thanks Steve. I appreciate your reply.

I implemented the Interceptor as a seperate class and used it with the session like you suggested.

It works NOW!!!

thanks again...


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