Thanks for the quick reply. I'm still not getting it to work (list-index column is null). Can you take a look at the following and see what I'm doing wrong?
Thx,
Gary
parent mapping
Code:
<hibernate-mapping>
<class name="mil.jfcom.model.Survey" table="SURVEY">
<id name="id" column="id" unsaved-value="null">
<generator class="increment" />
</id>
<property name="title" length="50" />
<property name="description" length="150" />
<list name="pages" table="PAGE" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="SURVEY_ID" />
<list-index column="PAGE_NUM" base="1" />
<one-to-many class="mil.jfcom.model.Page" />
</list>
</class>
</hibernate-mapping>
child mappingCode:
<hibernate-mapping>
<class name="mil.jfcom.model.Page" table="PAGE">
<id name="id" column="id" unsaved-value="null">
<generator class="increment" />
</id>
<property name="pageNumber" formula="PAGE_NUM" />
<property name="title" length="50" />
<many-to-one name="survey" column="SURVEY_ID" not-null="true" />
</class>
</hibernate-mapping>
parent codeCode:
public class Survey {
private Long id;
private String title;
private String description;
private List pages = new ArrayList();
public Survey() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List getPages() {
return pages;
}
public void setPages(List pages) {
this.pages = pages;
}
public void addPage(Page page) {
page.setSurvey(this);
pages.add(page);
}
}
child codeCode:
public class Page {
private Long id;
private Integer pageNumber;
private String title;
private Survey survey;
public Page() {
}
public Page(String title) {
this.title = title;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Survey getSurvey() {
return survey;
}
public void setSurvey(Survey survey) {
this.survey = survey;
}
}