-->
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: Conflicting getters
PostPosted: Wed Jun 19, 2013 7:13 pm 
Regular
Regular

Joined: Sun Aug 01, 2004 6:49 pm
Posts: 76
Recently I had following problem: Hibernate used an as transient annotated getter instead of the correct one. This resulted in a ClassCastException when handling the object. A sample class is attached below. So my question is:
Is this a bad design? (To have two members which might conflict.)
Is this probably a bug in Hibernate? (I did not check the latest release yet.)


Finally I renamed the transient getter to avoid the confusion.
Code:
public class Foo  {
   private Double manual = 0d;
   public Double getManual() {
      return manual;
   }
   public void setManual(Double manual) {
      this.manual = manual;
   }
   @Transient
   public boolean isManual() {
      return getManual() > 0;
   }
}

PS: I know it is probably no good design to have such similar names and conflicting getters, I only want to have clarity for the future.


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.