-->
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: Event System. How does it works?
PostPosted: Tue Apr 12, 2005 5:24 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Hibernate version:
3
--
Hi.
I'm seeking some examples and documentation on the new Event System, particulary the Save/Delete and flush events.
By first sight it looks like it's a big reorganization of Interceptor interface. But the interceptor has several limitations like:
- I can't use the session. I have to clone it with the same connection.
- The parameters are a mess:
onFlushDirty method is:
Code:
public boolean onFlushDirty(
           Object entity,
           Serializable id,
           Object[] currentState,
           Object[] previousState,
           String[] propertyNames,
           Type[] types)

1 - I have the entity that has the properties.
2 - I have the Id (I can get it in the entity);
3- I have current state, that I can get in the object. And it's an array (!?). I feel like I'm programming assembler here.
4- This is new information, but again in an array! why not an instance of the entity?
5- propertyName: I hate to search a name in an array to them get the value back in another list. It's a pain.
6- Types: This is tricky, but may be usefull.

Looks like the Event just put all this in a Event Object (like FlushEntityEvent).
Code:
public void onFlushEntity(FlushEntityEvent event)
...

flushentityevent wrapper. What does each method do ? where is the documentation of those classes??
Code:
Method Summary
Object[]    getDatabaseSnapshot()
           
int[]    getDirtyProperties()
           
Object    getEntity()
           
EntityEntry    getEntityEntry()
           
Object[]    getPropertyValues()
           
boolean    hasDatabaseSnapshot()
           
boolean    hasDirtyCollection()
           
boolean    isDirtyCheckHandledByInterceptor()
           
boolean    isDirtyCheckPossible()
           
void    setDatabaseSnapshot(Object[] databaseSnapshot)
           
void    setDirtyCheckHandledByInterceptor(boolean dirtyCheckHandledByInterceptor)
           
void    setDirtyCheckPossible(boolean dirtyCheckPossible)
           
void    setDirtyProperties(int[] dirtyProperties)
           
void    setHasDirtyCollection(boolean hasDirtyCollection)
           
void    setPropertyValues(Object[] propertyValues)
         

But what happens if I change a property of the entity during onFlushEntity execution of DefaultFlushEntityEventListener event implementation instead of changing it in the array of properties given by getPropertyMethods?
Because as I said on the Interceptor above, I think that it's really boring to change values in an array of objects when I have a powerfull Object To Relational Mapping tool.
And what If I want to query database? how do I do this? I still need to clone the session? but where is the session?
damn, I really want to belive that the Event System is better than this. But I can't find any information on how it works!
There is only one page of documentation on the reference guide in this subject :([/b]

_________________
Alexandre Torres
--------------------


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.