I'm getting an "xdoclet.XDocletException: Composite ID property of type void is
invalid. It has to be serializable and reimplement equals(Object)" on this object
graph. I can't figure out why. CategoryState extends State, which has an Identity.
Identity is Serializable and its concrete sub-classes do implement equals and
hashCode. Specifically, CategoryState's Identity is the concrete sub-class
CategoryIdentity. I specify the hibernate id tag on the setId() method. I've
simplified my classes quite a bit, but here's the code. Any help would be
appreciated. If I use my manually created mapping.xml, everything works correctly, so
it isn't a Hibernate issue.
public abstract class Identity implements Serializable {
public abstract boolean equals(Object obj);
public abstract int hashCode();
public abstract String toString();
}
public abstract class State implements Serializable {
protected Identity id;
public Identity getId() {
return id;
}
public abstract void setId(Identity identity);
public abstract String toString();
}
public class CategoryIdentity extends Identity {
private String categoryCode;
public CategoryIdentity() {
}
public CategoryIdentity(String categoryCode) {
this.categoryCode = categoryCode;
}
/**
* @hibernate.property
* column="category_code"
* type="com.*****.cc.hibernate.type.TrimStringType"
* length="2"
*/
public String getCategoryCode() {
return categoryCode;
}
public void setCategoryCode(String categoryCode) {
this.categoryCode = categoryCode;
}
public boolean equals(Object obj) {
if (obj instanceof CategoryIdentity) {
CategoryIdentity other = (CategoryIdentity) obj;
return (categoryCode.equals(other.categoryCode);
} else {
return false;
}
}
public int hashCode() {
return categoryCode.hashCode();
}
public String toString() {
return categoryCode;
}
}
/**
* @hibernate.class
* table="category"
* schema="ias"
*/
public class CategoryState extends State {
private String description;
public CategoryState() {
id = new CategoryIdentity();
}
public CategoryState(CategoryIdentity identity) {
id = identity;
}
public String getCategoryCode() {
return ((CategoryIdentity) id).getCategoryCode();
}
/**
* @hibernate.property
* column="description"
* type="com.*****.cc.hibernate.type.TrimStringType"
* length="50"
*/
public String getDescription() {
return description;
}
public void setCategoryCode(String categoryCode) {
((CategoryIdentity) id).setCategoryCode(categoryCode);
}
public void setDescription(String description) {
this.description = description;
}
/**
* @hibernate.id
* column="id"
* type="com.*****.cc.objectlib.CategoryIdentity"
* unsaved-value="null"
* generator-class="assigned"
*/
public void setId(Identity identity) {
if (identity instanceof CategoryIdentity) {
id = identity;
}
}
public String toString() {
StringBuffer temp = new StringBuffer();
temp
.append(id)
.append(" description=")
.append(description)
return temp.toString();
}
}
Eric
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user