-->
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.  [ 5 posts ] 
Author Message
 Post subject: idbag and interceptor
PostPosted: Tue Jun 29, 2004 9:38 am 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
Hi!
I'm using interceptor to log all the changes made into the database.
Now everybody in the project is using idbag to map the many-to-many relationships.

So, before there was a class that represented the relationship, and when an update was done it went through the interceptor and it was logged.

Now, with idbag we don't have this relationship class and the insertions don't go through the interceptor.

What can I do? Is the any option in this case?
I really need to log all the relationships.

Thanks in advance.

_________________
Ricardo K. Costa


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 1:18 pm 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
Nobody answered me... so I guess there isn't solution.
I really need this to work. But how??

Tks

_________________
Ricardo K. Costa


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 01, 2004 11:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No. This is a known limitation in the current flushing -> Interceptor notification. This has always been a limitation and has been discussed many many times (I even remember threads about it on the old sourceforge forums).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 4:41 pm 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 1:07 pm 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
I am trying to identify the inserted and deleted elements of the idbag collections, and I tryed to use the net.sf.hibernate.collection.IdentifierBag: 'needsInserting' and 'getDeletes()'.

Can I use them? I notice that not always I get the objects.
Am I using the wrong method?
Below is a piece of code I'm doing.

All help will be apreciated. Suggestions or new ideas...

--------

IdentifierBag ibg = (IdentifierBag) element.getGetter(cEntity).get(entity);
Iterator ite = ibg.iterator();
Object element;
while (ite.hasNext()) {
elemente = (Object) ite.next();
if( o.needsInserting(elemente, o.indexOf(elemente), null) )
{
// log data
}
}

ite = ibg.getDeletes(null);
while (ite.hasNext()) {
elemente = (Object) ite.next();
// log data
}

---------

Thanks in advance.

_________________
Ricardo K. Costa


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