-->
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.  [ 4 posts ] 
Author Message
 Post subject: benefit of usng property access strategy when access=field ?
PostPosted: Fri Mar 11, 2005 11:27 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 10:26 am
Posts: 22
hi there this is a nubiee question....

I was reading through the HIA book and on page 80 and have two questions , was hoping if you could shed some light on it

1. U describe that is a better stragetry to access attributes of a class via getter and setter methods.

Then what is the beneift of using access= "field" in the property tag ? Does it mean that i dont have to create getter and setter methods ?
When it is benefical to do this ?

2. In caveatemptor-0.9.5 ,in item.hbm.xml for example you have defined
.....
<!-- Name of the item is immutable. -->
<property name="name"
type="string"
column="NAME"
length="255"
not-null="true"
update="false"
access="org.hibernate.auction.persistence.DirectSetAccessor"/>

what is the benefit of the DirectSetAccessor ? Because in Item.java u do create a getter and setter method for the name attribute.

Thank you
-reeve


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 11:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
1. You can do whatever you like best, field or property method access.

2. Maybe a typo, but I don't really care much. See 1.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 11:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I've used my own accessor to apply a "mixed" strategy: It sets the field directly, but reads the value through a property accessor method. This is useful for immutable properties where no setter method should be exposed and you don't want to have a useless private setter.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 12:20 pm 
Beginner
Beginner

Joined: Wed Feb 23, 2005 10:26 am
Posts: 22
thank you Christian for your prompt reply


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