Team,
I faced a problem and i do have a solution for it, but i was wanting to understand as to why the hibernate code is written the way it is.
The problem is i have a mapping where i have a space in the column declaration.
Code:
.....
<property name="corporationId" type="java.lang.Integer" column="CORPORATION_ID " />
....
Now what happens is i will get the error that "JDBC error , column name not found...". However when i turn the trace on and get the exact sql from the command line and run the same in some tool, then the sql will work just fine.
Here is the code for the Integer value Type from hibernate.
Code:
public class IntegerType extends PrimitiveType implements DiscriminatorType, VersionType {
private static final Integer ZERO = new Integer(0);
public Object get(ResultSet rs, String name) throws SQLException {
return new Integer(rs.getInt(name));
}
....
This is the code that will generate the jdbc error above.
Now would it not help id we had the method like this
Code:
...
public Object get(ResultSet rs, String name) throws SQLException {
return new Integer(rs.getInt(name.trim()));
}
....
Or even better to have a trim() done before it even comes to this method. In fact for all the types in the
Code:
package net.sf.hibernate.type
This is just a sugesstion and there may be perfectly valid reason to do what has been done.
Please do excuse my understanding if it is not proper and also feel free to point out the mistake i have made if any.
Thanks for your wonderfull product.
Regards
Suchak Jani