-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to generate pojo with explicitly typed Sets
PostPosted: Fri May 22, 2009 1:18 pm 
Newbie

Joined: Tue Jul 29, 2008 8:08 am
Posts: 3
Location: Atlanta
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


Top
 Profile  
 
 Post subject: Re: How to generate pojo with explicitly typed Sets
PostPosted: Sat May 23, 2009 4:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
check the Generate Java 5 syntax option.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: How to generate pojo with explicitly typed Sets
PostPosted: Sat May 23, 2009 10:42 am 
Newbie

Joined: Tue Jul 29, 2008 8:08 am
Posts: 3
Location: Atlanta
Entirely too easy. Thanks.


Top
 Profile  
 
 Post subject: Re: How to generate pojo with explicitly typed Sets
PostPosted: Thu Jul 15, 2010 1:47 pm 
Newbie

Joined: Thu Jul 15, 2010 12:24 pm
Posts: 1
Hi jlw253,

I have been using hibernate to generate my hbm's and pojo's however, now when i try and regenerate these files, i cannot for some reason get hibernate to create sets for one-to-many relationships based upon foreign keys.
I am using jboss tools as an ide plugin on eclipse.
Is there anything special that you needed to do ?

How did you set this up ?


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

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.