-->
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.  [ 6 posts ] 
Author Message
 Post subject: Simulating triggers
PostPosted: Sat May 28, 2005 8:04 pm 
Beginner
Beginner

Joined: Sat May 07, 2005 12:01 pm
Posts: 33
Hi again!

Since trigger support is inconsistent across various databases, I'd like to see if I could simulate triggers via Hibernate. I looked at the interceptors and event handlers, but they don't allow me to react to "nitty gritty" events. In other words, I want to get a notification when Hibernate executes an INSERT or DELETE, e.g. when a link table row is added or removed (I want to use this to keep an audit history of relationship changes).

Any suggestions?

Thanks!

Jen


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2005 10:55 pm 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
hibernate 3x, event system
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#objectstate-events


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2005 11:00 pm 
Beginner
Beginner

Joined: Sat May 07, 2005 12:01 pm
Posts: 33
Thanks, but the event system is not fine-grained enough. I want to be notified when an actual INSERT SQL statement is executed, so I can track changes to link tables, not just entity objects.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2005 11:50 pm 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
you can audit history of relationship changes in object level. see
http://martinfowler.com/ap2/timeNarrative.html


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 29, 2005 4:23 am 
Beginner
Beginner

Joined: Sat May 07, 2005 12:01 pm
Posts: 33
Thanks for the pattern. Ideally, what I'd like to create an audit record whenever Hibernate creates or deletes a link table row -- I don't want to write this as custom persistence code.
This would be very easy with ON INSERT / ON DELETE triggers, but I want to be able to use a db like MySQL that doesn't support triggers that access other tables, so I'm looking for something like an interceptor...

Jen


Top
 Profile  
 
 Post subject: oversight in Auditing design?
PostPosted: Mon Jun 27, 2005 11:39 pm 
Newbie

Joined: Wed Apr 27, 2005 10:22 pm
Posts: 8
We've implemented auditing in our application using the design proposed in Hibernate In Action (pages 340 - 347). We're quite happy with it except for one thing. As the originator of this thread has reported, there does not seem to be a good way to hook into modifications that are made to link tables. Our only option seems to be to model our many-to-many as 2 one-to-manys and create a POJO that maps directly to the link table. Yuk. I really like being able to manage the many-to-many without creating a specific class and mapping for the link. Does anyone have a better solution? If not, I'd like to request that a future version of Hibernate support this. And if a second edition of the book is forthcoming, I think this limitation is defniitely worth calling out.

Thanks,
Max


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