-->
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.  [ 2 posts ] 
Author Message
 Post subject: Oracle objects mapping
PostPosted: Wed Sep 26, 2007 5:39 am 
Newbie

Joined: Mon Nov 21, 2005 2:24 pm
Posts: 8
I read this page about the mapping of oracle objects
http://www.hibernate.org/261.html
and tried to apply it, but it didn't work.
I have a table and one of its fields is a object defined as folows:
Code:
CREATE TYPE MyType as OBJECT(
MyName varchar2(10), MyNumber varchar2(10));

this object is included in a table mapped by the following XML file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="mypackage">
   <class
      name="AriaObj"
      table="ARIA_OBJ"
   >
      <meta attribute="sync-DAO">false</meta>
      <id
         name="Id"
         type="integer"
         column="ID"
      >
         <generator class="assigned"/>
      </id>
      <property
         length="1"
         name="Objfield"
         not-null="false"
         type="mypackage.MyType" >
         <column name="OBJFIELD" sql-type="MYTYPE" />         
      </property>
      <property
         name="Valfield"
         column="VALFIELD"
         type="string"
         not-null="false"
         length="10"
      />


   </class>   
</hibernate-mapping>


The class MyType.java is here
Code:
package mypackage;

public class MyType {
   private String myName;
   private String myNumber;
   
   public String getMyName() {
      return myName;
   }
   public void setMyName(String myName) {
      this.myName = myName;
   }
   public String getMyNumber() {
      return myNumber;
   }
   public void setMyNumber(String myNumber) {
      this.myNumber = myNumber;
   }
}

As soon as the application starts (before even connecting actually to the DB) I have the following error;
Code:

org.hibernate.MappingException: Could not determine type for: mypackage.MyType, for columns: [org.hibernate.mapping.Column(OBJFIELD)]
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
   at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
   at org.hibernate.mapping.Property.isValid(Property.java:185)
   at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
   at otherpackage.HibernateSessionFactory.buildSession(HibernateSessionFactory.java:119)
   at otherpackage.HibernateSessionFactory.currentGeomonitorSession(HibernateSessionFactory.java:68)
   at otherpackage.SessionManager.openSessionAndTransaction(SessionManager.java:21)
   at otherpackage.Main.saveNewMyType(Main.java:28)
   at otherpackage.Main.main(Main.java:20)


What am I doing wrongly?

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 26, 2007 10:17 am 
Newbie

Joined: Mon Nov 21, 2005 2:24 pm
Posts: 8
Got it!!
class MyType must implement org.hibernate.usertype.UserType.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.