14 Replies Latest reply on Mar 15, 2010 3:58 AM by Michael Glöckner

    howto setup jpa using oracle 10g unicode nvarchar2

    Michael Glöckner Newbie

      Hello folks,

       

      i like to setup jpa to use oracles nvarchar2 datatyp for string columns. Im using ejb3.0 and oracle 10.2.0.4.0

       

       

      I already tried the suggestions made in http://community.jboss.org/message/489679#489679, but the only think which worked out was the following annotation added to the specific String variables.

       

      @Column(columnDefinition="nvarchar2")
      
      

       

      But this would force me to implement the source code in a oracle database depended way.

      Is there any standard way to customize the datasource or the persistence.xml so the jpa framework is switching automatically to nvarchar2.

       

      my persistence.xml looks like:

       

         <persistence-unit name="MyPersistentUnit" transaction-type="JTA">
             <jta-data-source>java:/MyDS</jta-data-source>
             <properties>
                  <property name="hibernate.hbm2ddl.auto" value="create"/> 
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/> 
                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/MyEjbTestEntityManagerFactory"/>
             </properties>
         </persistence-unit>
      

      My ds.xml file looks like:

       <xa-datasource>
          <jndi-name>MyDS</jndi-name>
          <track-connection-by-tx/>
          <isSameRM-override-value>false</isSameRM-override-value>
          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
          <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:XE</xa-datasource-property>
          <xa-datasource-property name="User">user</xa-datasource-property>
          <xa-datasource-property name="Password">password</xa-datasource-property>
          <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
             <no-tx-separate-pools/>
        </xa-datasource>
      

       

      Thanks in advanced,

      Micha