-->
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.  [ 1 post ] 
Author Message
 Post subject: How to implement EmptyInterceptor.onCollectionUpdate()
PostPosted: Fri Sep 07, 2007 7:17 pm 
Newbie

Joined: Tue Jun 21, 2005 6:52 pm
Posts: 4
Hi All,

I am trying to store the history records for collections and I am facing the following problem.

The EmptyInterceptor has a method:

public void onCollectionUpdate(Object arg0, Serializable arg1)

I am trying to get the old and new values for a collection in this method. Here, arg0 is an instance of PersistentCollection. All our collections are implemented as HashSet, so arg0 is an instance of PersistentSet which is a subclass of AbstractPersistentCollection that implements PersistentCollection interface.

PersistentSet has two methods:

1. public Serializable getSnapshot(CollectionPersister persister) -> This can be used to get the modified collection which is yet to be flushed to the database (new collection)

2. public final Serializable getStoredSnapshot() -> This can be used to get the snapshot of stored collection in database (old collection)

http://www.hibernate.org/hib_docs/v3/api/index.html

I was planning to use these two methods to get the old and new collections, compare them based on 'id' to figure out what has been 'ADD'ed and what has been 'REMOVE'd from the collection.

The challenge I am currently facing is regarding the CollectionPersister.

I saw that there is a BasicCollectionPersister and OneToManyPersister that implement this interface indirectly, but they both require a constructor of the form:

OneToManyPersister(Collection collection, CacheConcurrencyStrategy cache, Configuration cfg, SessionFactoryImplementor factory)

BasicCollectionPersister(Collection collection, CacheConcurrencyStrategy cache, Configuration cfg, SessionFactoryImplementor factory)

I am kind of lost as to why we should pass a CollectionPersister to get the *new* collection. And whether we need to implement the CollectionPersister to get the *new* collection. Does anyone know whether there is any default implementation of the CollectionPersister?

Can you please let me know what I should be doing? Thanks a lot in advance.

Regards,
Sarin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.