Hi,
My requirement is to save Arabic characters to an Oracle DB where the char-set is not UTF-8, but Oracle National Language Support enabled.
So I tried to do the following based on these 2 links; and based on hibernate annotations.
http://oracle.su/docs/11g/java.112/e10589/global.htm#CHDHHJDBhttps://forum.hibernate.org/viewtopic.php?t=925490Code:
@TypeDef(
name = "utfStringType",
typeClass = UTFStringType.class
)
@Entity
@Table(name = "SPROUT_USERS")
public class User {
private String userName;
@Type(type = "utfStringType")
private String password;
// code continued....
}
The extended StringType is like this.
Code:
public class UTFStringType extends StringType{
private static final long serialVersionUID = -438204100185075979L;
public void set(PreparedStatement st, Object value, int index) throws SQLException {
if (st instanceof OraclePreparedStatement) {
((OraclePreparedStatement)st).setFormOfUse(index, OraclePreparedStatement.FORM_NCHAR);
System.out.println("*************** UTFStringType OraclePreparedStmt identified");
}
System.out.println("************* UTFStringType PreparedStmt class = " + st.getClass().getName());
super.set(st, value, index);
}
}
But when I try to save / retrieve the above entity, the set() method in the UTFString class is not invoked.
Kindly check if any step is wrong.
Thank you...