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?