Hibernate version:
3.1.3
Hibernate Tools plugin version:
3.2.0.beta6a
Hibernate Tools ant task version:
3.2.0.beta7
Name and version of the database you are using: oracle 9.2.0.6.0
I'm switching from using the plug-in for the reverse to using the Ant Task but have run into a problem with getting the Ant Task reverse to recognize the composite ID in the same way as the plug-in.
As an example, here is the Oracle DDL for the table:
Code:
CREATE TABLE TDOCUMENT_FSI
(
DOCUMENT_CODE VARCHAR2(64 BYTE) NOT NULL,
ID_DOCUMENT_TYPE NUMBER(10),
ID_EVENT NUMBER(10),
STATUS VARCHAR2(50 BYTE),
DOCUMENT BLOB NOT NULL,
ID_APPLICATION NUMBER(10),
TRANSFORM_STATUS VARCHAR2(2 BYTE) DEFAULT ' ' NOT NULL,
DOCUMENT_SIZE NUMBER(10),
TRANSFORM_TECH_ERROR CLOB,
TRANSFORM_FUNC_ERROR CLOB
)
/
CREATE UNIQUE INDEX PK_DOCUMENT_UNIQUE_KEY ON TDOCUMENT_FSI
(ID_EVENT, DOCUMENT_CODE, ID_DOCUMENT_TYPE)
/
The reveng for this table looks like:
Code:
<table name="TDOCUMENT_FSI" class="com.sgcib.fsi.fsio.hib.Document">
<primary-key>
<key-column name="ID_EVENT" property="eventId" />
<key-column name="DOCUMENT_CODE" property="docCode" />
<key-column name="ID_DOCUMENT_TYPE" property="docType" />
</primary-key>
<foreign-key constraint-name="FK_TDOCUMEN_APPLICATION">
<many-to-one property="application"/>
<set property="documents"/>
</foreign-key>
<foreign-key constraint-name="FK_TDOCUMEN_EVENT">
<many-to-one property="event"/>
<set property="documents"/>
</foreign-key>
<foreign-key constraint-name="FK_TDOCUMEN_DOCTYPE">
<many-to-one property="docType"/>
</foreign-key>
</table>
Running the plug-in produces this
Document.hbm.xml:
Code:
<!-- Generated Aug 29, 2006 4:56:35 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="com.sgcib.fsi.fsio.hib.Document" table="TDOCUMENT_FSI">
<composite-id name="id" class="com.sgcib.fsi.fsio.hib.DocumentId">
<key-many-to-one name="event" class="com.sgcib.fsi.fsio.hib.TransformationEvent">
<column name="ID_EVENT" precision="10" scale="0" />
</key-many-to-one>
<key-property name="docCode" type="string">
<column name="DOCUMENT_CODE" length="64" />
</key-property>
<key-many-to-one name="docType" class="com.sgcib.fsi.fsio.hib.DocumentType">
<column name="ID_DOCUMENT_TYPE" precision="10" scale="0" />
</key-many-to-one>
</composite-id>
<many-to-one name="application" class="com.sgcib.fsi.fsio.hib.Application" fetch="select">
<column name="ID_APPLICATION" precision="10" scale="0" />
</many-to-one>
<property name="status" type="string">
<column name="STATUS" length="50" />
</property>
<property name="document" type="blob">
<column name="DOCUMENT" not-null="true" />
</property>
<property name="transformStatus" type="string">
<column name="TRANSFORM_STATUS" length="2" not-null="true" />
</property>
<property name="documentSize" type="java.lang.Long">
<column name="DOCUMENT_SIZE" precision="10" scale="0" />
</property>
<property name="transformTechError" type="clob">
<column name="TRANSFORM_TECH_ERROR" />
</property>
<property name="transformFuncError" type="clob">
<column name="TRANSFORM_FUNC_ERROR" />
</property>
</class>
</hibernate-mapping>
But running the following ant-task:
Code:
<hibernatetool destdir="${DIR.SRC}">
<jdbcconfiguration configurationfile="${DIR.CNF}/hibernate.cfg.xml"
revengfile="${DIR.CNF}/hibernate.reveng.xml" />
<hbm2hbmxml/>
<hbm2java jdk5="true" />
</hibernatetool>
gives a warning message in the Ant console:
Code:
[hibernatetool] WARNING: The JDBC driver didn't report any primary key columns in TDOCUMENT_FSI. Asking rev.eng. strategy
and produces this
Document.hbm.xml:
Code:
<!-- Generated Aug 29, 2006 4:17:14 PM by Hibernate Tools 3.2.0.beta7 -->
<hibernate-mapping>
<class name="com.sgcib.fsi.fsio.hib.Document" table="TDOCUMENT_FSI">
<composite-id name="id" class="com.sgcib.fsi.fsio.hib.DocumentId">
<key-property name="eventId" type="java.lang.Long">
<column name="ID_EVENT" precision="10" scale="0" />
</key-property>
<key-property name="docCode" type="string">
<column name="DOCUMENT_CODE" length="64" />
</key-property>
<key-property name="docType" type="java.lang.Long">
<column name="ID_DOCUMENT_TYPE" precision="10" scale="0" />
</key-property>
</composite-id>
<many-to-one name="event" class="com.sgcib.fsi.fsio.hib.TransformationEvent" update="false" insert="false" fetch="select">
<column name="ID_EVENT" precision="10" scale="0" />
</many-to-one>
<many-to-one name="docType" class="com.sgcib.fsi.fsio.hib.DocumentType" update="false" insert="false" fetch="select">
<column name="ID_DOCUMENT_TYPE" precision="10" scale="0" />
</many-to-one>
<many-to-one name="application" class="com.sgcib.fsi.fsio.hib.Application" fetch="select">
<column name="ID_APPLICATION" precision="10" scale="0" />
</many-to-one>
<property name="status" type="string">
<column name="STATUS" length="50" />
</property>
<property name="document" type="blob">
<column name="DOCUMENT" not-null="true" />
</property>
<property name="transformStatus" type="string">
<column name="TRANSFORM_STATUS" length="2" not-null="true" />
</property>
<property name="documentSize" type="java.lang.Long">
<column name="DOCUMENT_SIZE" precision="10" scale="0" />
</property>
<property name="transformTechError" type="clob">
<column name="TRANSFORM_TECH_ERROR" />
</property>
<property name="transformFuncError" type="clob">
<column name="TRANSFORM_FUNC_ERROR" />
</property>
</class>
</hibernate-mapping>
This second Document.hbm.xml doesn't recognize the composite ID in the same way and doesn't produce the expected code.
Anything that I can do for this?
thanks in advance