• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple set() methods on the same property in a POJO

 
Dave Segal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a mapped POJO has multiple set() methods for the same property (with different signatures, of course), which one does Hibernate use?

I have set up a mapping and the following works just fine:

public void setProp(String val) {this.prop = new Prop(val);}

However, I get an Exception when I add a second set method, such as:

public void setProp(Prop val) {this.prop = val;}

It seems like whenever I have two setters for the same property, I get an exception. I have tried various combinations of property types and set methods, and it seems that my basic problem is that two setters on the same property generates an exception.

Is there a way that I can direct Hibernate to use the correct setter and ignore the others?

Thanks,
Dave
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure that Hibernate uses the Introspector so you might try implementing BeanInfo to explicitly describe which set method to use.

It's just a guess as I haven't tried it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic