Ok, this just took me a while to figure out so I thought I’d share it here.
If you have a boolean variable that follows the naming convention “isValue” (e.g. boolean isPerson = false;
), then the according mapping file property name may not include the “is” part of the name, for example:
<property name="person" column="is_person" />
Otherwise, Hibernate throws some weird Exceptions.
In my case it was:
Initial SessionFactory creation failed.org.hibernate.InstantiationException: could not instantiate test object FOO Caused by org.hibernate.InstantiationException: could not instantiate test object BAR Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.NoClassDefFoundError: Could not initialize class BAR
Hint: Inside your Java class, the following conventions must be used for getter and setters:
public boolean isPerson();
public void setPerson();
Don’t use:
public void setIsPerson();
!!!