Here's the story...
I ran Hibernate plugin for Middlegen against my database to generate mapping docs. Surprisingly, it ran fine ;-) (~350-table Oracle schema).
Then I ran hbm2java to generate POJOs... It didn't go as well as I expected. Having done some reseach, I traced the problem down to somewhat erroneous mapping file. Here it is:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="airline.hibernate.IncomeType"
table="INCOME_TYPE"
>
<property
name="description"
type="java.lang.String"
column="DESCRIPTION"
length="32"
/>
<id
name="incomeTypeId"
type="long"
column="INCOME_TYPE_ID"
>
<generator class="assigned" />
</id>
<property
name="code"
type="java.lang.String"
column="CODE"
length="32"
/>
<!-- associations -->
<!-- bi-directional one-to-many association to RegularFinancialEvent -->
<set
name="regularFinancialEvents"
lazy="true"
inverse="true"
>
<key>
<column name="INCOME_TYPE_ID" />
</key>
<one-to-many
class="airline.hibernate.RegularFinancialEvent"
/>
</set>
</class>
</hibernate-mapping>
The bad thing about the file above is it has 'id' element after 'property' element which violates the DTD.
I traced it down further into database. Here's the scipt that's used to create the table above:
CREATE TABLE income_type (
description varchar2 (32),
income_type_id number (10) NOT NULL,
code varchar2 (32),
constraint income_type_pk
primary key ( income_type_id ))
So it looks like the order of columns poses a problem to the plugin.
Am I doing something wrong?
Is it a known issue?
Thanks,
Borys