-->
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.  [ 4 posts ] 
Author Message
 Post subject: Whitch dialect used to create the Oracle XMLType
PostPosted: Fri Aug 19, 2005 10:09 am 
Beginner
Beginner

Joined: Tue Jul 05, 2005 4:44 am
Posts: 40
Location: Paris, France
Hello,

Hibernate version: 3.05
Name and version of the database you are using:Oracle 9.2

I would like to use Oracle XMLType.
So, I create a class witch implements UserType.
Code:
public class OracleXMLType implements UserType, Serializable {
    /**
    *
    */
   private static final long serialVersionUID = -6722439738091377161L;

   private static Log log = LogFactory.getLog(OracleXMLType.class);
   
   private static final int[] SQL_TYPES = new int[] { oracle.xdb.XMLType._SQL_TYPECODE }; 
    private static final Class RETURNED_CLASSES = String.class;
   
    /**
     * @see org.hibernate.usertype.UserType#sqlTypes()
     */
    public int[] sqlTypes() {
       StringBuffer buffer = new StringBuffer();
       for (int i = 0; i < SQL_TYPES.length; i++) {
          buffer.append(SQL_TYPES[i]).append(";");
       }
       log.info(buffer.toString());
        return SQL_TYPES;
    }

    /**
     * @see org.hibernate.usertype.UserType#returnedClass()
     */
    public Class returnedClass() {
        return RETURNED_CLASSES;
    }
  [...]

Mapping documents:
To uses OracleXMLType, I map this like :
Code:
<hibernate-mapping package="fr.test.model.persistance">
<class name="XMLBody" table="XML_BODY">
   <id name="dbId" column="XML_BODY_DB_ID">
      <generator class="assigned"></generator>
   </id>
   <property    name="body"
            type="fr.test.service.persistance.OracleXMLType"
            column="XML_BODY_BODY"
            not-null="true">
   </property>
</class>   
</hibernate-mapping>


Code:
<hibernate-configuration>   
    <session-factory>   
      <!-- Enable CGLIB reflection optimizer (enabled by default) -->
       <property name="hibernate.cglib.use_reflection_optimizer">false</property>
   
      <!-- With Application Server -->
      <property name="connection.datasource">jdbc/etso</property>
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

        <!-- Mapping files -->
resource="fr/test/model/persistance/XMLBody.hbm.xml"/>                       
    </session-factory>
</hibernate-configuration>


Full stack trace of any exception that occurs:
When export the schema with schema export, I have a "Schema text failed"

Quote:
[schemaexport] 19 août 2005 15:52:53 org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing foreign key constraints
[schemaexport] 19 août 2005 15:52:54 fr.rte.etso.service.persistance.OracleXMLType sqlTypes
[schemaexport] INFO: 2007;

BUILD FAILED
C:\logiciel\eclipse-SDK-3.1.0-win32\workspace\EtsoPrototype\build.xml:24: Schema text failed: No Dialect mapping for JDBC type: 2007


The value 2007 is the oracle.xdb.XMLType._SQL_TYPECODE.
So, I ask you if people knows the dialect to used to generate XMLType ?

Thx for your help !!

_________________
Fred


Top
 Profile  
 
 Post subject: Re: Whitch dialect used to create the Oracle XMLType
PostPosted: Fri May 06, 2011 4:13 am 
Newbie

Joined: Sat Mar 26, 2011 5:03 am
Posts: 2
It's never too late...
Code:
package your.package;

import org.hibernate.dialect.Oracle10gDialect;

public class OracleDialectWithXmlSupport extends Oracle10gDialect {

   public OracleDialectWithXmlSupport() {
      super();
      registerHibernateType(oracle.xdb.XMLType._SQL_TYPECODE, "xmltype");
      registerColumnType(oracle.xdb.XMLType._SQL_TYPECODE, "xmltype");
   }
}

Why is this not supported in the Oracle10gDialect ?


Top
 Profile  
 
 Post subject: Re: Whitch dialect used to create the Oracle XMLType
PostPosted: Wed Oct 12, 2011 4:00 am 
Newbie

Joined: Tue Oct 11, 2011 10:37 am
Posts: 3
thomasvst! Thanks for saving my day.


Top
 Profile  
 
 Post subject: Re: Whitch dialect used to create the Oracle XMLType
PostPosted: Tue Nov 15, 2011 2:08 pm 
Newbie

Joined: Tue Nov 15, 2011 2:01 pm
Posts: 1
I am getting following error when i added registerHibernateType(oracle.xdb.XMLType._SQL_TYPECODE, "xmltype") in Oracle10gDialect

java.lang.NullPointerException
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:505)
at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:451)
at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:348)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:639)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
at com.citi.gts.alto.model.InstructionDataTest.main(InstructionDataTest.java:95)

Could any please help me?


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

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.