Parameter value did not match expected type
This was fixed by placing the classes with the JPA annotations and enum classes into the domain-dir/lib/applib directory. You have to place these classes in a JAR in the domain-dir/lib/applib directory and then specify the jar on the deploy command with asadmin using the
--libraries jar1,jar2,etc. Do not place a space after the comma when listing multiple JAR files.
Also, I had a common JAR that had EJB remote interfaces, so I had to break out my JPA classes into a new JAR and place them in my applibs directory also. I then put the JAR with the EJB remote interfaces into my EAR\lib directory.
The JARs in the lib/applibs directory are loaded by the URLClassLoader. The JARs in the EAR\lib are loaded by the EARLibClassLoader.
I guess the main problem is that you are trying to use an enum datatype on the database side. This is not recommended because it often requires an proprietary enum type which may not be well supported by the JPA implementation (e.g. Hibernate). See this answer on a similar question for some details.
Further, with the annotation
you are saying that you explicitly want, that the value is saved as a String in the database. I would expect that this fails if the real column type is some enum. Maybe the Hibernate code changes are trying to prevent these problems by forcing you to use either varchar or integer columns.
Use a varchar column with
@Enumerated(EnumType.String) or an int column with
You can try to specify the enum column via the annotation
@Basic(optional = false) @Column(name = "state", columnDefinition = "enum('UP','DOWN','RETRY')") @Enumerated(EnumType.String) private State state;
You can try to specify your enum class via an hibernate XML mapping file:
<property name="type" column="type" not-null="true"> <type name="org.hibernate.type.EnumType"> <param name="enumClass">package.name.State</param> <param name="type">12</param> <!-- 12 is java.sql.Types.VARCHAR --> </type> </property>
- JPA enumerated types mapping. Best approach
- Enum in Hibernate, persisting as an enum
- MySQL Enum performance advantage?