3

嗨,,

我使用@ElementCollection 映射对象类列表,但我遇到了消息问题:

java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean     with name 'ObjWellSvc': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.prosia.wmls.service.repo.ObjWellRepo com.prosia.wmls.service.impl.ObjWellSvcImpl.objWellRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ObjWellRepo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.prosia.wmls.service.repo.impl.BaseImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/D:/NetBeansProjects/WITSML%20(Energistic)/WitsServer/src/java/cfg/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: collection element mapping has wrong number of columns: com.prosia.witsml.dataobject.CsCustomData.any type: object
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.prosia.wmls.service.TesterClass.<clinit>(TesterClass.java:19)

这是该领域的声明:

@ElementCollection
@CollectionTable(name="any", joinColumns=@JoinColumn(name="customdataID"))
@Column(name="any_")
protected List<Object> any;

所以任何人都可以帮助我......解决这个问题......

谢谢

4

1 回答 1

3

您尝试持久化 java.lang.Object 的任意实例。根据 JPA 2.0,支持以下类型:

实体的持久字段或属性可以是以下类型: Java 原始类型;java.lang.String; 其他 Java 可序列化类型(包括原始类型的包装器、java.math.BigInteger、java.math.BigDecimal、java.util.Date、java.util.Calendar[5]、java.sql.Date、java.sql.Time , java.sql.Timestamp, byte[], Byte[], char[], Character[],以及实现Serializable接口的用户定义类型);枚举;实体类型;实体类型的集合;可嵌入类(参见第 2.5 节);基本类型和可嵌入类型的集合(参见第 2.6 节)。

于 2012-07-06T11:40:50.993 回答