So, does that mean, that it is impossible to get the length of column in UserType?
Because ... I'm defining my own UserType called FixedString and in nullSafeSet method I'd like to fill all string values with blanks (up to length of that column defined with annotation:
@Column(length=100, nullable=true)).
I have no problem to trim all strings in nullSafeGet method (with StringUtils.trim method):
Code:
public Object nullSafeGet(ResultSet inResultSet, String[] names, Object o) throws SQLException {
String val = (String)Hibernate.STRING.nullSafeGet(inResultSet, names[0]);
return StringUtils.trim(val);
}
,but I have no idea how I can get the length of current column (in my case COLUMN_LENGTH).Code:
public void nullSafeSet(PreparedStatement inPreparedStatement, Object o, int i) throws SQLException {
String val = (String)o;
inPreparedStatement.setString(i, StringUtils.rightPad(val, COLUMN_LENGTH)));
}
Any idea how I can get the length (defined in by the @Column annotation) in UserType?
Thanks a lot for any help!
Rob