-->
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.  [ 2 posts ] 
Author Message
 Post subject: idbag Collection hbm2java
PostPosted: Tue May 01, 2007 10:45 am 
Newbie

Joined: Thu Oct 26, 2006 1:34 pm
Posts: 11
Hi,
i am using hbm2java to generate my Java Files from my hmg.xml files. My code does it look like 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 name="StoryVO" table="STORY">
      <id name="storyId" type="long" column="STORY_ID">
        <meta attribute="scope-set">protected</meta>
        <generator class="native"/>
      </id>
      <property name="title" type="string" column="STORY_TITLE" not-null="true"/>
      <property name="intro" type="string" column="STORY_INTRO"/>
      <property name="body" type="text" column="STORY_BODY"/>     
     <!-- Comments -->               
     <idbag name="comments"
            table="STORY_COMMENT">           
           
            <collection-id type="long" column="STORY_COMMENT_ID">
               <generator class="native"/>
            </collection-id>
           
            <key column="STORY_ID"/>
           
            <composite-element class="StoryCommentVO">          
          <property name="body" type="text" column="COMMENT_BODY"/>
           </composite-element> 
     </idbag>   
</hibernate-mapping>


The java generated file is:

Code:
// Generated 1/05/2007 16:20:08 by Hibernate Tools 3.2.0.beta8

import java.util.Collection;

public class StoryVO  {
    // Fields   
     private long storyId;
     private String title;
     private String intro;
     private String body;
     private Collection comments;

     // Constructors


    /** default constructor */
    public StoryVO() {
    }

   /** minimal constructor */
    public StoryVO(String title) {
        this.title = title;
    }

    /** full constructor */
    public StoryVO(String title, String intro, String body, Collection comments) {
       this.title = title;
       this.intro = intro;
       this.body = body;
       this.comments = comments;
    }

   

    // Property accessors
    public long getStoryId() {
        return this.storyId;
    }

   

    protected void setStoryId(long storyId) {
        this.storyId = storyId;
    }

    public String getTitle() {
        return this.title;
    }

   
    public void setTitle(String title) {
        this.title = title;
    }

    public String getIntro() {
        return this.intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getBody() {
        return this.body;
    }

    public void setBody(String body) {

        this.body = body;

    }   

    public Collection getComments() {

        return this.comments;

    }

   

    public void setComments(Collection comments) {

        this.comments = comments;

    }
}


I would like the line
Code:
private Collection comments;

to be:
Code:
private Collection comments = new ArrayList();


Is this possible?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 3:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
tools questions should be in tool forum - and try using the latest which should handle this specific issue and if it doesn't work report it in our jira.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.