I am using hibernate 3.2.5.
I have a pojo with id defined as java.math.BigDecimal and associated to an oracle sequence. The following is the sample of mapping file
Code:
<hibernate-mapping>
<class name="pojo.A" table="TABLE_A">
<id name="id" type="big_decimal">
<column name="ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">seq_a_id</param>
</generator>
</id>
</class>
</hibernate-mapping>
When I persist the object I get the following exception,
org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or stringI looked at the source code, it seems like the sequence is generated for int, short, long or String. If I add 3 lines of code (marked below) it works.
Code:
// 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);
}
//added the following 3 lines
else if ( clazz==java.math.BigDecimal.class ) {
return rs.getBigDecimal(1);
}
else {
throw new IdentifierGenerationException("this id generator generates long, integer, short or string");
}
}
Is there a JIRA # already opened for this? If yes then is there a plan to include the fix in next release ?
In the meantime can I change the code and use the modified jar file without licensing issue? Is this the right fix even?