-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate + annotation mapping type + oracle NLS
PostPosted: Thu Nov 04, 2010 9:25 am 
Newbie

Joined: Thu Nov 04, 2010 9:04 am
Posts: 1
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#CHDHHJDB
https://forum.hibernate.org/viewtopic.php?t=925490

Code:
@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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.