gpt4 book ai didi

java - 来自 EclipseLink 的 PersistenceUnitLoadingException

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:40:45 24 4
gpt4 key购买 nike

我已经开发了一个 jpa 示例,但是没问题但是我在使用 jpa 运行另一个示例时遇到错误,下面给出了一个错误

on [EclipseLink-30005] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExceptionException Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupExceptionException Description: Predeployment of PersistenceUnit [testjpa] failed.Internal Exception: Exception [EclipseLink-7212] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationExceptionException Description: The attribute [updatedTime] from the entity class [class entity.Product] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.        at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:133)        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)        at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)        at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)        at test.SurveyTest.main(SurveyTest.java:21)Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupExceptionException Description: Predeployment of PersistenceUnit [testjpa] failed.Internal Exception: Exception [EclipseLink-7212] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationExceptionException Description: The attribute [updatedTime] from the entity class [class entity.Product] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:991)        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:88)        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:124)        ... 4 moreCaused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupExceptionException Description: Predeployment of PersistenceUnit [testjpa] failed.Internal Exception: Exception [EclipseLink-7212] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationExceptionException Description: The attribute [updatedTime] from the entity class [class entity.Product] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.        at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)        ... 7 moreCaused by: Exception [EclipseLink-7212] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationExceptionException Description: The attribute [updatedTime] from the entity class [class entity.Product] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.        at org.eclipse.persistence.exceptions.ValidationException.noTemporalTypeSpecified(ValidationException.java:1395)        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processTemporal(MappingAccessor.java:1590)        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processJPAConverters(MappingAccessor.java:1358)        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingConverter(MappingAccessor.java:1422)        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingValueConverter(MappingAccessor.java:1440)        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.BasicAccessor.process(BasicAccessor.java:300)        at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processAccessors(MetadataDescriptor.java:1287)        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processAccessors(ClassAccessor.java:825)        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processAccessors(EntityAccessor.java:847)        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:708)        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1333)        at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:461)        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:390)        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:945)        ... 6 moreJava Result: 1

最佳答案

Exception Description: The attribute [updatedTime] from the entity class [class entity.Product] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.

您必须使用@Temporal 注释该字段:http://download.oracle.com/javaee/6/api/javax/persistence/Temporal.html

指定它是 DATE、TIME 还是 TIMESTAMP。

关于java - 来自 EclipseLink 的 PersistenceUnitLoadingException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8171761/

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