-->
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: getRole() returns null in Interceptor.onCollectionRecreate()
PostPosted: Wed Feb 01, 2006 1:19 pm 
Newbie

Joined: Wed Aug 03, 2005 11:04 am
Posts: 10
Hibernate version:
3.1.2 (brand new ;-) )

Problem:

I am using the "new" onCollectionRecreate(Object collection, Serializable key) and onCollectionUpdate(Object collection, Serializable key) methods in the org.hibernate.Interceptor to implement an audit trail in the interceptor.

For that reason I cast the given collection to a PersistentCollection if possible and use the getRole()-method to determine which collection has been altered.

Code:
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
   if (collection instanceof PersistentCollection) {
      PersistentCollection pc = (PersistentCollection) collection;
      System.out.println("Update on "+pc.getRole()+":"+ key.toString());
   }
}


This approach works fine for me in the update scenario, the output is as expected. But for the recreate case where I just created a new Entity, saved [session.save(entity)] and then flushed it I just get a "null" from pc.getRole().

Is this the intended behaviour? Am I missing something?
I tried to wade through the Hibernate code and see where that role is set, but these paths back to the HbmBinder are very tricky :-(.

Any thoughts anyone?


Top
 Profile  
 
 Post subject: Re: getRole() returns null in Interceptor.onCollectionRecreate()
PostPosted: Tue May 19, 2009 7:32 am 
Regular
Regular

Joined: Tue Feb 17, 2009 5:13 am
Posts: 59
Hi all.

I'm in the same situation. I'm intercepting collections creation (and updates) and to manage it correctly, for each collection intercepted, I need to know the following data:
i) The type of collection elements
ii) The owner type
iii) The name of the owners' field which maps the collection

I am able to know the first two, but I can't to know the last one, and I need it!

Anybody knows something about?
Thanks in advance. Best regards.

_________________
Born to lose... live to win!


Top
 Profile  
 
 Post subject: Re: getRole() returns null in Interceptor.onCollectionRecreate()
PostPosted: Thu Oct 07, 2010 12:22 pm 
Beginner
Beginner

Joined: Wed May 23, 2007 1:07 pm
Posts: 28
I have the same question, which is the same as in

http://opensource.atlassian.com/project ... e/HHH-3129

So, onCollectionRecreate is there any way to know where the collection comes from (ie, owner + property name)?
How can one compare its items with the items currently in the collection?


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.