-->
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.  [ 8 posts ] 
Author Message
 Post subject: User customized accessors
PostPosted: Thu Dec 01, 2005 10:55 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
Hi

I was trying to find an example on how to define a user customized Setter and Getter (I mean, I know how to implement it, I just couldn't find the correct place to define it in the configuration, i.e. map the setter/getter to the correct class...). I was wondering if someone could point the place in the documentation on how to do that (I might have been looking for the wrong terms..).

thanks
Gadi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 2:23 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You do not need to map custom methods, use properties without side effect for mapping and add as many methods as you need for side effects or encapsulation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 10:23 am 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
I'm not sure I understand how this could help, I'll try with an example:
I have a property which is a user defined type, and I don't want to (actually can't) make it extend UserType, and I don't want to serialize it (I will if I had to, overriding the serialzation methods) - its getter and setter need to return its type (can't return something else - there are clients already using it). So, providing my own Getter and Setter for this class should work fine (I'll place the same logic there as I'd have done in the serialization code, but I think that's what the Setter/Getter hooks are there for, isn't it?)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 10:31 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Perhaps I got this wrong, but
your user defined type does not need to implement UserType.

The UserType class is parallel to your user defined type.
It just creates and uses them.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 10:32 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
And I forgot, if you want to have an example
for custom accessors, look at:
BasicPropertyAccessor
thats the one hibernate is using.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 10:41 am 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
ok, great, now, the only thing I'm missing is how to map my own custom Accessor into Hibernate (hopefully there's a way to do that without extending PropertyAccessorFactory)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
use the name of your custom class in the access attribute:
Code:
<property ... access="MyCustomAccessor"/>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 3:49 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
Thanks!


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