gpt4 book ai didi

java - @ElementCollection 用于映射 Object 类的列表

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:56:49 25 4
gpt4 key购买 nike

喂,,

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

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

谢谢

最佳答案

您尝试持久化 java.lang.Object 的任意实例。根据 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).

关于java - @ElementCollection 用于映射 Object 类的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11358567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com