I have used this all the time, but now it's no longer working. Really strange. Code snippet:
@Column(name = "STAT", length = 16)
@Enumerated(EnumType.STRING)
private State state = State.LIVE;
...
public enum State {
LIVE,
DELETED;
}
In the db, there are only values stored with LIVE or DELETED. No nulls.
But i'm getting: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.DescriptorException Exception Description: No conversion value provided for the value [0] in field [WERK.STAT]. Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[state-->WERK.STAT]
It seems to me, that the ordinal ('...provided for the value [0]...') comes - somehow - into place, but i don't know why and how to get rid of it.
I'm using glassfish 3.1.2 which uses eclipselink 2.3.2. I upgraded to eclipselink 2.4.2 with the same result. It's weird, because it's running on my development machine without any problems. I'm using mysql 5.6.14.
Thx
Got it. The exception text is finally wrong. I found that [0] value, but in a completely different table (which has no reference to WERK at all) and has been imported using an sql script containing these [0] values (my fault). So, if you have ever a similar problem you have to check the whole database content, not just those mentioned.
The error resides on the DB query, make a query and find if the enums values match with the properties in the enum class, if not then make an adjustment into the Database if this is possible, and if not maybe you could find what are the values for your enum properties.
Might be an error in the database values or fine, the number of values differs from the values that you need to validate.
select distinct(state) from WERK;
this should devolve only to those two values that you are enum (LIVE,EDIT). If not that is the cause of your problem.