-->
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.  [ 7 posts ] 
Author Message
 Post subject: idbag Collection hbm2java
PostPosted: Wed May 02, 2007 9:31 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 9:44 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
http://forum.hibernate.org/viewtopic.php?t=973966

Max wrote:
try using the latest which should handle this specific issue and if it doesn't work report it in our jira

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 9:51 am 
Newbie

Joined: Thu Oct 26, 2006 1:34 pm
Posts: 11
adamgibbons wrote:
http://forum.hibernate.org/viewtopic.php?t=973966

Max wrote:
try using the latest which should handle this specific issue and if it doesn't work report it in our jira


Hi,
I did not understand what is meant by "try using the latest". That it is why i posted again in the Tools forum. What is the latest?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 3:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
latest as in use the latest version of hibernate tools.

you use b8; you should try b9

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 7:24 am 
Newbie

Joined: Thu Oct 26, 2006 1:34 pm
Posts: 11
I tried with b9 but i still get the same issue. Had anyone an idea or should i post in jira?

Code:
package com.cerebra.cerepedia.story;

// Generated 3/05/2007 13:18:37 by Hibernate Tools 3.2.0.b9



....
...
..
.
     private Collection comments;



Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 4:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if not already in jira then report it ;)

work around is to use

Code:
<meta attribute="default-value">new java.util.ArrayList()</meta>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 4:16 am 
Newbie

Joined: Thu Oct 26, 2006 1:34 pm
Posts: 11
Thanks that worked!


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