HY ,,
我使用@ElementCollection映射List类的Object,但是我遇到了一条消息问题:
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;
所以任何人都可以帮助我......解决这个问题...
谢谢
答案 0 :(得分: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)。