-->
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.  [ 1 post ] 
Author Message
 Post subject: @Immutable annotation for immutable properties
PostPosted: Fri Nov 30, 2007 4:47 pm 
Beginner
Beginner

Joined: Thu Sep 16, 2004 8:14 pm
Posts: 27
I am using Hibernate 3.2.5 and I would like to mark some properties of a persisted class as immutable. I want to be able to create new instances of this class and save those values, but once saved I want the setter to throw an exception stating that the property cannot be modified. Is that what the method level annotation @Immutable is supposed to do?
I have annotated one of my methods as:

@Immutable
@Column(nullable=false)
public String getSummary() {
return _summary;
}

but after retrieving one of these objects from the database I can call setSummary("foo") and the value gets persisted.
Thanks in advance for any help with this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.