-->
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: Direct field access
PostPosted: Fri Jan 16, 2004 12:04 pm 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
The API doc says that BasicPropertyAccessor (through getter/setter) is the recommended strategy : why is it better than DirectPropertyAccessor (access fields directly) ?

DirectPropertyAccessor let me put some business logic in my setters (check correctness of attribute) that do not have to be checked when I retrieve objects from db.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Depends, sometimes you want to do stuff in your setters/getters that need to be done even when data comes from the db. Besides it is better for maintainability.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 12:21 pm 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
And what happens if my setter method throw an application specific exception ? Does hibernate encapsulate it inside an HibernateExcpetion ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 1:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It probably depends, but I would say no.
For sure, your Exception must be runtime.
I don't think the JavaBean spec allow exception in getter/setter.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 1:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It will, the InvocationTargetException which wraps the exception the setter throws (from the reflection call) will be wrapped in a PropertyAccessException (subclass of HibernateException)


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.