christian,
hello, I tried your codes thousands of time. But it could not work.
The follows are the java codes generated by
net.sf.hibernate.tool.hbm2java.CodeGenerator
Code:
package airline.hibernate;
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class Group implements Serializable {
/** identifier field */
private String id;
/** nullable persistent field */
private String myname;
/** nullable persistent field */
private airline.hibernate.Group parentGroup;
/** persistent field */
private Set childGroups;
/** full constructor */
public Group(java.lang.String myname, airline.hibernate.Group parentGroup, Set childGroups) {
this.myname = myname;
this.parentGroup = parentGroup;
this.childGroups = childGroups;
}
/** default constructor */
public Group() {
}
/** minimal constructor */
public Group(Set childGroups) {
this.childGroups = childGroups;
}
public java.lang.String getId() {
return this.id;
}
public void setId(java.lang.String id) {
this.id = id;
}
public java.lang.String getMyname() {
return this.myname;
}
public void setMyname(java.lang.String myname) {
this.myname = myname;
}
public airline.hibernate.Group getParentGroup() {
return this.parentGroup;
}
public void setParentGroup(airline.hibernate.Group parentGroup) {
this.parentGroup = parentGroup;
}
public java.util.Set getChildGroups() {
return this.childGroups;
}
public void setChildGroups(java.util.Set childGroups) {
this.childGroups = childGroups;
}
public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof Group) ) return false;
Group castOther = (Group) other;
return new EqualsBuilder()
.append(this.getId(), castOther.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getId())
.toHashCode();
}
}
I got the error like
NoClassFoundError:airline/hibernate/Group (wrong name: airline/hibernate/Group)
at java.lang. Classloader.defineClass0(native method)
This error is not the "common class not fond error",
I deleted many-to-one and set tag in hbm.xml. It
Works!!!!
Can you tell me why?