Hi...
- My database is MySQL e all the PK are 'autoincrement'
- I'm using the follow ID TAG:
<id name="id" type="package.IdToLongConverter" column="id"> <generator class="native" /> </id>
- The IdToLongConverter is a org.hibernate.usertype.UserType class
- When I put 'null' in a id value, occours this error:
org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
- I looked at the source code Hib3 and I verified that it doesn't support UserType...
- In IdentifierGeneratorFactory.get(ResultSet, Type) display:
// unhappy about this being public ... is there a better way?
public static Serializable get(ResultSet rs, Type type)
throws SQLException, IdentifierGenerationException {
Class clazz = type.getReturnedClass();
if ( clazz==Long.class ) {
return new Long( rs.getLong(1) );
}
else if ( clazz==Integer.class ) {
return new Integer( rs.getInt(1) );
}
else if ( clazz==Short.class ) {
return new Short( rs.getShort(1) );
}
else if ( clazz==String.class ) {
return rs.getString(1);
}
// in this POINT I need support to UserType
else {
throw new IdentifierGenerationException("this id generator generates long, integer, short or string");
}
}
Are there a solution for this my problem? Thank's.
_________________ Leonardo Pereira
Rio de Janeiro, Brazil
|