Guys, look at what I'm trying to do...
I have a class that encapsulate the hibernate methods, in there I'm trying to figure out who are the idBag collections, discover who is been inserted and deleted in those collections to finally log these data.
Below there what I've already done.
public class AbstractFactory{
...
public void update(final Object entity) throws Exception {
setFlushMode(FLUSH_AUTO);
LogHistoricoInterceptor.writeHistoricoIdBag(entity);
session.update(entity);
}
...
}
public class LogHistoricoInterceptor{
...
public static void writeHistoricoIdBag(Object entity)
{
try{
Class cEntity = entity.getClass();
Configuration conf = TribApp.getInstance().getConfiguration();
PersistentClass classconf = conf.getClassMapping(cEntity);
Iterator it = classconf.getPropertyIterator();
Property element = null;
while (it.hasNext()) {
element = (Property) it.next();
if ( element.getValue() instanceof
net.sf.hibernate.mapping.IdentifierBag )
{
IdentifierBag o =
(IdentifierBag) element.getGetter(cEntity).get(entity);
// Need to identify the new objects of the collection and the deleted.
// Maybe with queuedAdditionIterator??
}
}catch(Exception err)
{
err.printStackTrace();
}
}
So, can I discover who are these objects (the inserted and deleted)??
Thanks
_________________ Ricardo K. Costa
|