Hi All, I'm very new to hibernate and am using annotations for about a week now, but i believe i stumbled upon some strange behaviour. If i'm totally out of line and in the wrong place for my findings, please tell me and I won't cause any more spam on this list :)
I've got a property annotated as follows: @Generated(GenerationTime.INSERT) @Column(insertable=false) Now reading the documentation, i was let to believe this property should show up in the sqlUpdateStrings, but it didn't. So, looking at the internal hibernate-annotations code i saw this code in PropertyBinder.make(): (It's hibernate-annotations-3.2.0cr1) if (generated != null) { if ( ! GenerationTime.NEVER.equals( generated ) ) { if ( property.isAnnotationPresent( javax.persistence.Version.class ) && GenerationTime.INSERT.equals( generated ) ) { throw new AnnotationException("@Generated(INSERT) on a @Version property not allowed, use ALWAYS: " + StringHelper.qualify( holder.getPath(), name ) ); } if ( prop.isInsertable() ) { throw new AnnotationException("Cannot have @Generated property and insertable columns: " + StringHelper.qualify( holder.getPath(), name ) ); } if ( GenerationTime.ALWAYS.equals( generated ) && prop.isUpdateable() ) { throw new AnnotationException("Cannot have @Generated(ALWAYS) property and updatable columns: " + StringHelper.qualify( holder.getPath(), name ) ); } prop.setInsertable( false ); prop.setUpdateable( false ); prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) ); } } now, why are the calls to prop.setInsertable( false ) and prop.setUpdateable( false ) happening? It seems rather strange since they are checked before to see whether or not they are in conflict with the set GenerationTime, but then are overruled, so that the property will be neither insertable nor updateable. By commenting out these calls, the expected behaviour took placed (at least, expected by me) in that the property showed up in the update string, but not in the insert string. Also the other properties which had GenerationTime.ALWAYS (and corresponding column settings) did not show up in neither the insert nor the update string. So am I right in the conclusion that these calls shouldn't be made (and therefor posting to this list was A Good Thing;)? cheers, Willem Voogd ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel