我正在尝试将我的项目从休眠 3.6 升级到 4.1.6,我想我已经把所有的罐子都放在了正确的位置,等等,但现在我在谷歌搜索下面有这个异常没有得到答案。我的代码在 Hibernate 3.6 上运行良好,我不确定这是我的映射问题还是其他问题。我正在使用 JPA 方法使用 Spring 3.1.2 配置休眠 4.1。
Caused by: org.hibernate.MappingException: Could not create DynamicParameterizedType for type: org.hibernate.type.EnumType
at org.hibernate.mapping.SimpleValue.createParameterImpl(SimpleValue.java:398)
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:304)
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:1738)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 55 more
Caused by: java.lang.ClassNotFoundException: char
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.mapping.SimpleValue.createParameterImpl(SimpleValue.java:389)
... 64 more
更新:我在休眠代码中设置了断点,该异常被捕获并找到了它不喜欢的映射,下面是它。
@Entity
@Table(name = "company_addresses")
public class CompanyAddress extends TimeStampedPersistableObject
{
public enum AddressType
{
PUBLIC('p'), SHAREHOLDER('s');
private final char typeCode;
AddressType(char typeCode)
{
this.typeCode = typeCode;
}
public static AddressType parse(char c)
{
for (AddressType addressType : AddressType.values())
{
if (addressType.value() == c)
{
return addressType;
}
}
return null;
}
public char value()
{
return typeCode;
}
}
@Column(name = "address_type")
@Enumerated(EnumType.STRING)
private char type;