Hi,
I am seeing some odd behaviour with hbm2java.
- hibernate version 2.12
- extensions 2.02.
I am using <meta> tags in my hbm file in order to create base classes (i.e. plumbing/linking etc., occurs in super class). This seemed (from what I have read) to be common practice and worked well... until I required a class with a <composite-element > within a set. I have a simplified mapping below...
Code:
<class name="test.Test" table="test">
<meta attribute="generated-class">test.BaseTest</meta>
<id name="id" column="id" type="long" unsaved-value="0" >
<generator class="identity" />
</id>
<property name="name" type="java.lang.String"/>
<set name="members" table="test_members" lazy="true">
<key column="id"/>
<composite-element class="test.Member">
<meta attribute="generated-class">test.Member</meta>
<property name="memberProperty" type="java.lang.Integer"/>
<many-to-one name="user" class="com.fonem.vbx.db.User"/>
</composite-element>
</set>
</class>
There are two <meta> tags in the class definition.
If I omit both of them, the classes are generated as you would expect.
If I insert just the first meta tag to force the generator create 'test.BaseTest', it will only generate one class (test.BaseTest) and the contents of the file are what you would expect in test.Member. i.e. test.BaseTest is generated with properties of memberProperty and user, with id, name, and members nowhere to be seen.
If I insert the both meta tags, specifying that the composite-element class to be test.Member, the problem is solved and the two classes are generated correctly.
So what is the big deal you ask? Well, it seems that I can not use the hbm file with both meta tags, as the standard hibernate parser barfs on it. For example, if I try to generate DDL, I get the following....
Code:
[java] Caused by: org.xml.sax.SAXParseException: The content of element type "composite-element" must match "(parent?,(property|many-to-one|any|nested-composite-element)*)".
It would seem the dtd being used by the standard parser does not allow meta tags in composite-elements.
- Steven