I'm trying to use the generate-class metatag to generate base classes for persistence, as per:
http://www.onjava.com/pub/a/onjava/2005/12/14/hibernate-class-generation-with-hbm2java.html?page=last
I am using Hibernate 3.1.3CIP with Hibernate Tools 3.1. What I notice is that for any class that contains a composite-id, I don't see generated properties other than those contained in the composite-id itself. For example, this:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class mutable="true" name="Test" table="test">
<meta attribute="generated-class">TestBase</meta>
<composite-id name="id" class="com.bgi.ips.identifier.composite.TestId">
<meta attribute="use-in-equals">true</meta>
<key-property name="issueId" column="issue_id" type="integer" />
<key-property name="issueCodeType" column="issue_cd_type" type="string" />
</composite-id>
<property name="code" type="string">
<column name="issue_cd" />
</property>
</class>
</hibernate-mapping>
produces this:
public class TestBase implements java.io.Serializable {
Code:
// Fields
private Integer issueId;
private String issueCodeType;
// Constructors
/** default constructor */
public TestBase() {
}
...
(Notice the missing "code" property.)
This problem seems to be universal for me. As soon as I replace the <composite-id> with a normal <id> tag, it generates all the properties. I have no idea why this would be the case. Is this a bug, or am I doing something wrong?
David