-->
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.  [ 3 posts ] 
Author Message
 Post subject: Why do Interceptors pass Object arrays?
PostPosted: Fri Mar 26, 2004 5:15 am 
Regular
Regular

Joined: Fri Dec 12, 2003 2:09 pm
Posts: 84
Location: San Francisco, USA
Implementing the Interceptor interface requires me to map Object arrays of current/future state onto the properties of my persistent objects. Why represent the state as Object arrays, rather than, say, a Map from (property name)->(property value), similar to the Distributed Objects pattern? or perhaps even instances of the persistent class?

http://www.hibernate.org/161.html

Has anyone developed any good patterns to assist/automate this mapping? To date, I have simply implemented some utility methods that build up a maps of (property name)->(Object[] index) for each persistent class... I am betting that the order of the properties in the Object array are static once the mapping files are loaded.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 28, 2004 11:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I have implemented something like this. Check out http://hibernate.bluemars.net/156.html for details (specifically the stuff relating to the PropertyDelta interface towards the end).

Generally maps will not work here. There will be times when you'll need both the original value as well as the new value. Kind of hard to do that with a simple Map structure.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 12:40 am 
Regular
Regular

Joined: Fri Dec 12, 2003 2:09 pm
Posts: 84
Location: San Francisco, USA
I glanced at that pattern before, but didn't appreciate it -- thanks for "helping" me take a closer look.

Indeed, a map is not itself useful for maintaining deltas between new/old state. But two maps would work nicely for this :)

I suppose it just depends on the use case/access pattern. If the Interceptor is just going to iterate over all state and doesn't actually care which property it is (just it's type or whatever), then the Object[] arrays are fine. But if you want to correlate the new/old values back to specific properties, having a map seems like it would be a lot more useful.


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