This week's book giveaway is in the Testing forum.
We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!
See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

It is posible to define the persistence version attribute over a type obtained using generics?

Manuel Carnerero
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maybe the question itself is not very clear. I will explain it. I have some basic classes to define entities extending from them with the objetive of avoiding recoding always the same basic things. In this case I have the class:

In this class the ID and the VERSION are generic types that I can set when I define the entity class. The @version annotation alerts me that it isn't a valid type for a version attribute, but I supposed that if declare the class Person using Long class for the ID and the VERSION it should work. When I try to launch the web application in a glassfish server (4.x), it generates the error:

Caused by: Exception [EclipseLink-7168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [curVer] of type [class java.lang.String] on the entity class [class] is not valid for a version property. The following types are supported: int, Integer, short, Short, long, Long, Timestamp.
at org.eclipse.persistence.exceptions.ValidationException.invalidTypeForVersionAttribute(
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.VersionAccessor.process(
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processMappingAccessors(
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processMappingAccessors(
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.processMetamodelDescriptor(
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(
... 62 more

Thank you in advance and sorry about my english.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic