-->
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.  [ 2 posts ] 
Author Message
 Post subject: Modify Setters Methods
PostPosted: Mon Dec 15, 2003 4:20 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
Is possible to do that a setter method return a value, for example: I need a method similar to this:

public [b]boolean[/b] setHeight(int height) {
If(height > 100) {
this.height = height;
return true;
} else
return false;
}

But Hibernate launch an exception...
Thanx a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 4:53 pm 
Newbie

Joined: Fri Oct 31, 2003 9:17 am
Posts: 10
Location: USA
Are you trying to perform some data validation here? Why not throw an exception instead?

Code:
public void setHeight (int val) {
    if (val < 100) {
        throw new IllegalArgumentException();
    }
    this.height = val;
}



hope this helps


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