-->
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: AuditInfoType and Hibernate3
PostPosted: Mon May 09, 2005 3:27 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.3

Mapping documents:

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

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:

AuditInfoType example from page 48.html page in web site does not work in Hibernate 3 because of deepcopy method: Hibernate.TIMESTAMP.deepcopy does not have this signature in this release.
Any solution?


Top
 Profile  
 
 Post subject: Found it yet?
PostPosted: Thu Aug 11, 2005 6:54 pm 
Beginner
Beginner

Joined: Tue Sep 21, 2004 1:49 pm
Posts: 33
Location: Bogota, Colombia
Hi, did you find a solution for this problem?

The signature of deepcopy is really "exotic" for newbies.. :(


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 4:22 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
Here I send you my actual method.

It works for me.

I have translated variable names from Spanish into English in this example. if you see any variable that is not ok it is because of the translation...

There are two commented lines that correspond to the previous release 2 lines.
As you can see, there is no need to deepCopy them because casted value object already solves the problem.

Anyway, I have all this audit interceptor classes working as expected since Hibernate release 2. I do not mind giving you some words of advice if needed.


/*
* Returns deep copy of persisten state.
*
*/
public Object deepCopy(Object value)
throws HibernateException
{
if (value == null) {
return null;
}

AuditInfo ai = (AuditInfo) value;
AuditInfo result = new AuditInfo();

try {
result.setCreatedBy(ai.getCreatedBy());
result.setDateCreated(ai.getDateCreated());
//result.setDateCreated((Timestamp) Hibernate.TIMESTAMP.deepCopyNotNull(
//ai.getDateCreated()));
result.setEditedBy(ai.getEditedBy());
result.setDateEdited(ai.getDateEdited());
//result.setDateEdited((Timestamp) Hibernate.TIMESTAMP.deepCopyNotNull(
//ai.getDateEdited()));

return result;
} catch (Exception e) {
e.printStackTrace();

return result;
} finally {
ai = null;
}
}


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.