Hibernate version: 3.2.5GA , and mapping done as referred
for one-to-one relations at
http://www.hibernate.org/hib_docs/v3/re ... tional-121.
But keeps on failing(stacktrace in last paragraph) saying I must
map an identifier of type long created natively !??!!?
Mapping documents:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name=mypackage.SimpleService"
table="SERVICES">
<id name="id" column="SERVICE_ID">
<generator class="native"/>
</id>
<one-to-one name="permissions"/>
<property name="date" type="timestamp"
column="CREATION_DATE"/>
<set name="names" table="SERVICE_NAMES">
<key column="SERVICE_ID"/>
<element column="name" unique="true"
not-null="true" type="string"/>
</set>
</class>
<class name="mypackage.ServicePermissions"
table="SERVICE_PERMISSIONS">
<id name="id" column="SERVICE_ID">
<generator class="foreign">
<param name="property">SimpleService</param>
</generator>
</id>
<one-to-one name="serviceId" constrained="true"/>
<map name="permissions" table="SERVICE_USERPERMISSIONS" cascade="all">
<key column="id_servicepermissions"/>
<index column="usr" type="string"/><!--pq obliga a meter index-->
<many-to-many column="id_permissions"
class="mypackage.Permissions"/>
</map>
</class>
<class name="mypackage.Permissions" table="PERMISSIONS">
<id name="id" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="usr" type="string" not-null="true"/>
<property name="read" type="boolean" not-null="true"/>
<property name="write" type="boolean" not-null="true"/>
<property name="execute" type="boolean" not-null="true"/>
<property name="delete" type="boolean" not-null="true"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.ExceptionInInitializerError
at mypackage.HibernateUtil.<clinit>(HibernateUtil.java:19)
at mypackage.SimpleServer.main(SimpleServer.java:164)
Caused by: org.hibernate.MappingException: An association from the table SERVICE_PERMISSIONS refers to an unmapped class: long
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1134)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
at mypackage.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 1 more