I am trying to use custom / user defined wrapper classes with Hibernate. For example, I have an immutable class that wraps a String. It has a default constructor as well as a constructor that accepts a String. But, it does not have a set() method. I modified the setters to do a new() to work around this:
private ExpIDCncr expID; public ExpIDCncr getExpID() {return expID;} public void setExpID(String expID) { this.expID = new ExpIDCncr(expID);}
My wrapper classes work on simple operations, but throw a ClassCastException if they must participate as a property in a 1:M relationship or as part of a composite key.
Can anybody give me any tips on this, or are immutable classes simply incompatible with Hibernate? What are the rules for using user defined classes for bean properties in Hibernate? If I switch my wrapper class back to a String, everything works just fine.
Thanks, Dave
PS - I have read, and re-read setion 4.2.4, Custom Value Types, of the doc. I can't seem to make the leap from documentation to code.
|