有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

对象类映射列表的java@ElementCollection

Hy,,

我使用@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;

所以任何人都可以帮助我。。。要解决此问题

谢谢


共 (1) 个答案

  1. # 1 楼答案

    您可以尝试持久化java的任意实例。朗,反对。根据JPA 2.0,支持以下类型:

    The persistent fields or properties of an entity may be of the following types: Java primitive types; java.lang.String; other Java serializable types (including wrappers of the primitive types, 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[], and user-defined types that implement the Serializable interface); enums; entity types; collections of entity types; embeddable classes (see Section2.5); collections of basic and embeddable types (see Section 2.6).