-->
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: Property access requires set method?
PostPosted: Sun May 06, 2007 8:14 am 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
From the Hibernate book I read that you require property access for identifiers to prevent certain problems.
My question is if you must always have a setId method or just the getId will suffice, because I don't want to be able to update the id in Java code.

And what if I have a property with update="false". Do I still need a set method for that property if it has property access.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 12:05 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
You can set your set methods to private if you don't want to expose them.

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 8:26 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
You can also use access="field" in the id mapping, which will bypass setters and getters altogether.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 2:48 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
Ananasi wrote:
You can also use access="field" in the id mapping, which will bypass setters and getters altogether.


No, like I said I wanted to use properties to prevent certain problems.
Something needed property acess for id's.
Actually forgot what the problem was that I tried to prevent :)
I thought it had something to do with conversations.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 2:49 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
himawan wrote:
You can set your set methods to private if you don't want to expose them.


Thanks. So easy that I didn't think about it :)
Maybe package access is not too bad too, to prevent warnings in my Intellij IDEA that private field is never set.


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.