-->
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: hbm2java generates setter
PostPosted: Wed Jan 31, 2007 11:45 pm 
Newbie

Joined: Tue Jan 23, 2007 9:42 pm
Posts: 6
Location: Kansas City, MO USA
Hibernate version: 3.2.1

Mapping documents:
...
<many-to-one name="createdBy" column="CREATED_BY" class="User" cascade="none" update="false" not-null="true" foreign-key="FK_USER_CREATED_BY"/>
...


hbm2java generates Java source with a setter method even though I've asked that the property be not updatable.

Code:
public User getCreatedBy() {
  return this.createdBy;
}
   
public void setCreatedBy(User createdBy) {
  this.createdBy = createdBy;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 2:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it still need to be set initially when the data is loaded from the source.

But you could argue that the setter should be made protected and/or private.

You can fix that by adding a <meta attribute="scope-set">private</meta>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 11:41 am 
Newbie

Joined: Tue Jan 23, 2007 9:42 pm
Posts: 6
Location: Kansas City, MO USA
Yes that would work.

I'd like to have the default scope be private when the field is not updatable, but then would that force the access to be field for this property or can hibernate still work with private setter methods?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 12:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sure.

_________________
Max
Don't forget to rate


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.