-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to generate inner class "CategorizedItem$Id"
PostPosted: Tue Dec 25, 2007 12:06 am 
Newbie

Joined: Mon Dec 24, 2007 10:48 pm
Posts: 1
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?




Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.