The version of hibernate-tools.jar I used with hibernate2 was 2.1.3 as shown from the readme.txt file in the jar file.
Code:
Hibernate Tools - Tools for Hibernate
=====================================
version 2.1.3, 18. November 2004
The Hbm.xml file is identical to the one in the original post except for the 2.0/3.0 dtd change.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.hibernate">
<class mutable="true" lazy="false" name="com.hibernate.Test" table="TEST">
<meta attribute="scope-get">private</meta>
<meta attribute="scope-set">private</meta>
<id name="id" column="ID" type="long">
<generator class="assigned" />
</id>
<property name="col1" column="COL1" type="java.lang.String">
<meta attribute="scope-get">public</meta>
</property>
<property name="col2" column="COL2" type="java.lang.String">
<meta attribute="scope-set"></meta>
<meta attribute="scope-get">public</meta>
</property>
<property name="col3" column="COL3" type="java.lang.String">
</property>
<property name="col4" column="COL4" type="java.lang.String">
</property>
</class>
</hibernate-mapping>
Here is the output from 'hbm2java' with hibernate 2.
Code:
package com.hibernate;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class Test implements Serializable {
/** identifier field */
private Long id;
/** nullable persistent field */
private String col1;
/** nullable persistent field */
private String col2;
/** nullable persistent field */
private String col3;
/** nullable persistent field */
private String col4;
/** full constructor */
public Test(Long id, String col1, String col2, String col3, String col4) {
this.id = id;
this.col1 = col1;
this.col2 = col2;
this.col3 = col3;
this.col4 = col4;
}
/** default constructor */
public Test() {
}
/** minimal constructor */
public Test(Long id) {
this.id = id;
}
private Long getId() {
return this.id;
}
private void setId(Long id) {
this.id = id;
}
public String getCol1() {
return this.col1;
}
private void setCol1(String col1) {
this.col1 = col1;
}
public String getCol2() {
return this.col2;
}
void setCol2(String col2) {
this.col2 = col2;
}
private String getCol3() {
return this.col3;
}
private void setCol3(String col3) {
this.col3 = col3;
}
private String getCol4() {
return this.col4;
}
private void setCol4(String col4) {
this.col4 = col4;
}
public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}
}
Since the work around is fairly easy (don't use set-scope at the class level), this isn't a big concern for me. I just thought you would want to be aware of it.