openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Re: enum = null becomes blank string in db
Date Fri, 03 Apr 2009 16:26:37 GMT
Just tested this with static enhancement against mysql and have the same 
problem. OpenJPA is inserting a blank string into the not-null field when the 
the enum variable is null.

Is this a bug or to be expected?


Adam Hardy on 01/04/09 17:38, wrote:
> I have an entity bean with this property in v1.2.0 and H2 db:
> <basic name="numericDisplay">
>   <column name="NUMERIC_DISPLAY"/>
>   <enumerated>STRING</enumerated>
> </basic>
> I just discovered that I can set the property on the bean to null and 
> save it to a field in the DB with a not-null constraint. It saves a 
> zero-length string.
> On reading back the row however OpenJPA throws this:
> <openjpa-1.2.0-r422266:683325 nonfatal general error> 
> org.apache.openjpa.persistence.PersistenceException: No enum const class 
> org.permacode.patternrepo.PatternRepoNumericDisplay.
> Surely this is inconsistent? Shouldn't I get an error when trying to do 
> the write first of all?
> Admittedly I have yet to test it with pre-enhanced beans but I figured 
> it would be the same (or is that a completely different code base?)

View raw message