-->
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: Possible bug with reflection of methods in entities
PostPosted: Tue Dec 16, 2008 11:30 am 
Newbie

Joined: Tue Dec 16, 2008 11:20 am
Posts: 1
I think I may have found a bug with the way Hibernate looks to do reflection of method names. The below code snippets define my entity mapping in the abstract class then overrides the function names for alternate use in the concrete class. Running the code results in an IllegalArgumentException saying expected boolean, but got Byte. It appears hibernate is not looking through all available methods with the same name, but just picking the first (or an arbitrary ) one when doing the reflection. I have a work around by just renaming the methods dealing with the Byte to getEnabledByte/setEnabledByte. I have not looked at the source, but thought I'd pass this on to others who have more time to investigate.

From AbstractUserdata.java (Generated)
Code:
   @Column( name = "enabled", unique = false, nullable = false )
   public Byte getEnabled()
   {
      return this.enabled;
   }
   
   public void setEnabled( Byte enabled )
   {
      this.enabled = enabled;
   }


I have an interface, UserData
Code:
     public boolean isEnabled();

     public void setEnabled( boolean enabledValue );


finally in my entity Userdata.java I implement the interface
Code:
@Entity
@Table(name = "userdata", catalog = "xxxxx")
public class Userdata extends AbstractUserdata implements UserData
{
    ....

   @Transient
   public boolean isEnabled()
   {
      if ( getEnabledByte() == ( byte ) 1 )
         return true;
      else
         return false;
   }

   @Transient
   public void setEnabled( boolean enabledValue )
   {
      if ( enabledValue )
         setEnabledByte( ( byte ) 1 );
      else
         setEnabledByte( ( byte ) 0 );
      
   }
}


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.