I'm using Eclipse along with Hibernate tools to generate my pojo and mapping files from an existing database schema.
Everything is running VERY well with one small exception.
When the pojos are generated their one-to-many relationships are speficied via Sets that are un-typed.
When I browse the Configuration via Hibernate Console in Eclipse, all of these classes include Sets that are explicitly typed with the class of the related object. The generated hbm.xml mapping files DO include the one-to-many references to the desired class -- it's just that the generated domain .java files don't include the type information.
My question is this: How can I configure reverse engineering such that the Sets created in the pojo are accompanied with their specific object types?
Here's a pared-down example to illustrate what I'm seeing.
Database DDL:
Code:
CREATE TABLE enterprise (
enterpriseID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
CONSTRAINT PRIMARY KEY (enterpriseID)
);
create table completionpackage (
completionPackageID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
enterpriseID BIGINT UNSIGNED NOT NULL,
CONSTRAINT PRIMARY KEY (completionPackageID),
CONSTRAINT FOREIGN KEY (enterpriseID) REFERENCES enterprise(enterpriseID)
);
Generated hbm.xml:
Code:
<hibernate-mapping>
<class name="...Enterprise" table="enterprise" catalog="phoenix_internal">
<id name="enterpriseId" type="java.lang.Long">
<column name="enterpriseID" />
<generator class="identity" />
</id>
<set name="completionpackagereports" inverse="true">
<key>
<column name="enterpriseID" not-null="true" />
</key>
<one-to-many class="...Completionpackagereport" />
</set>
</class>
</hibernate-mapping>
Generated .java pojo:
Code:
package ...;
// Generated May 19, 2009 9:20:17 AM by Hibernate Tools 3.2.2.GA
/**
* Enterprise generated by hbm2java
*/
public class Enterprise implements java.io.Serializable {
private Long enterpriseId;
private Set completionpackagereports = new HashSet(0);
. . .
Under the Hibernate Console in Eclipse I see:
Code:
- Hibernate Console
- Configuration
- (class) Enterprise
- enterpriseId:Long
- completionpackages:Set<Completionpackage>
So the tool knows that completionpackages should be "Set<Completionpackage>" but the generated pojo just uses the un-typed "Set".
Is there a way to change to reverse engineering config so the type makes it through to the pojo?
Thank you - Jackson