Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate EnumType instantiation exception
    text
    copied!<p>I'm using hibernate 4 and xml based mapping. Here is the exception I'm getting</p> <pre><code>Caused by: org.hibernate.MappingException: Unable to instantiate custom type: org.hibernate.type.EnumType at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) at org.hibernate.type.TypeFactory.custom(TypeFactory.java:179) at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:103) at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:130) at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:307) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:294) at org.hibernate.mapping.Property.isValid(Property.java:238) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:469) at org.hibernate.mapping.RootClass.validate(RootClass.java:270) at org.hibernate.cfg.Configuration.validate(Configuration.java:1294) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1788) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:189) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:350) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1504) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1502) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 35 more Caused by: java.lang.NullPointerException at org.hibernate.type.EnumType.setParameterValues(EnumType.java:153) at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:131) at org.hibernate.type.TypeFactory.custom(TypeFactory.java:189) ... 53 more </code></pre> <p>And here is the enum mapping that I'm using</p> <pre><code>&lt;property name="coachingStatus" column="status" update="true" insert="true" index="true"&gt; &lt;type name="org.hibernate.type.EnumType"&gt; &lt;param name="enumClass"&gt;com.tutorial.enums.CoachingStatus&lt;/param&gt; &lt;param name="type"&gt;12&lt;/param&gt; &lt;/type&gt; &lt;/property&gt; </code></pre> <p>And here is the enum:</p> <pre><code>public enum CoachingStatus { ACTIVE, BLOCKED, PENDING, EXPIRED } </code></pre> <p>here is the entity</p> <pre><code>public class Coaching implements Serializable { private Integer id; private String name; private Long locationId; private Integer organisationId; private Long ownerId; private Date createdOn; private Date modifiedOn; private CoachingStatus coachingStatus; private Long createdBy; private Long modifiedBy; private String email; private String logo; private String about; private String phone; ... //getters and setters } </code></pre> <p>I checked out tutorial from here - <a href="http://blog.javachap.com/index.php/enumeration-mapping-in-hibernate/" rel="noreferrer">here</a> but I'm getting above error. Need help with this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload