Hibernate version: 3.2.2ga
Mapping documents:
To focus the problem, I simplified CategorizedItem.hbm.xml, Item.hbm.xml and Categorized.hbm.xml, and merge them into a single file All.hbm.xml as bellow:
All.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="auction.model">
<class name="CategorizedItem" table="CATEGORIZED_ITEM"
mutable="false">
<composite-id name="id" class="CategorizedItem$Id">
<key-property name="categoryId" column="CATEGORY_ID"
type="long" />
<key-property name="itemId" column="ITEM_ID" type="long" />
</composite-id>
<property name="dateAdded" column="ADDED_ON" type="timestamp"
not-null="true" />
<many-to-one name="item" class="Item" column="ITEM_ID"
not-null="true" insert="false" update="false" />
<many-to-one name="category" class="Category"
column="CATEGORY_ID" not-null="true" insert="false" update="false" />
</class>
<class name="Category" table="CATEGORY">
<id name="id" type="long" column="CATEGORY_ID">
<generator class="identity" />
</id>
<property name="name" type="string" column="CATEGORY_NAME" not-null="true"/>
<set name="categorizedItems" cascade="all, delete-orphan"
inverse="true">
<key column="CATEGORY_ID" not-null="true" />
<one-to-many class="CategorizedItem" />
</set>
</class>
<class name="Item" table="ITEM">
<id name="id" type="long" column="ITEM_ID">
<generator class="identity" />
</id>
<property name="name" type="string" not-null="true"
update="false" column="ITEM_NAME" />
<set name="categorizedItems" cascade="all, delete-orphan"
inverse="true">
<key column="ITEM_ID" not-null="true" />
<one-to-many class="CategorizedItem" />
</set>
</class>
</hibernate-mapping>
================================
hbm2java in the task SchemaExport of Ant will throw the Exception:
java.lang.ClassNotFoundException: auction.model.CategorizedItem$Id
Alternatively, I used myeclipse 6.0.1 to generate the POJO based on these three hbm.xml files, but there will be four .java files:
Category.java,
Item.java,
CategoryItem.java, and
Id.java, I just want three java files with inner static class Id in CategoryItem.java,
is there any way making this Id.java auto generated into CategoryItem.java as inner class?
I have tried to figure it out using <meta attribute="class-code">, but it needs coding manually in some parts also.
what's more, I even want to spend time on modifying .ftl template
(Just plan for now, since modifying ftl will cost most of the time, If there is no choice, the finally option is modifying the ftl).
is there any way making this Id.java auto generated into CategoryItem.java as inner class?