I'm having problems with an one-to-one relation.
The error is:
Code:
ERROR - (BasicPropertyAccessor.java:118) - IllegalArgumentException in class: data.Employee, setter method of property: storeOwner
ERROR - (BasicPropertyAccessor.java:122) - expected type: data.StoreOwner, actual value: java.lang.Boolean
ERROR - (CustomersPanel.java:586) - IllegalArgumentException occurred while calling setter of data.Employee.storeOwner
This doesn't says the problem is the one-to-one relation, but I started getting this error when I changed a many-to-one to an one-to-one relation.
I have 2 objects StoreOwner and Employee. Each StoreOwner is an Employee, an Employee doesn't has to be a StoreOwner.
Below are the mappings and classes:
Code:
<class name="data.StoreOwner" table="storeOwners">
<id name="id" column="id" length="31">
<generator class="assigned" />
</id>
<many-to-one name="employee" class="data.Employee" column="employee" unique="true" />
</class>
<class name="data.Employee" table="employees">
<id name="id" column="id" length="31">
<generator class="assigned" />
</id>
<one-to-one name="storeOwner" class="data.StoreOwner" property-ref="employee" />
</class>
Code:
public class StoreOwner extends Data
{
private Employee employee;
public StoreOwner()
{
}
public Employee getEmployee()
{
return employee;
}
public void setEmployee(Employee employee)
{
this.employee = employee;
}
}
public class Employee extends Data
{
private StoreOwner storeOwner;
public Employee()
{
}
public StoreOwner getStoreOwner()
{
return storeOwner;
}
public void setStoreOwner(StoreOwner storeOwner)
{
this.storeOwner = storeOwner;
}
}
The problem occurs when I save a new Employee.
I've got this from
5.1.13. One-to-one and I've never used an one-to-one relation in Hibernate before.
Does anyone has an idea? Am I missing an attribute in the mapping?