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.