I have two classes for right now to demonstrate the issues I'm encountering:
public interface Project {
int getId();
void setId(int id);
String getName();
void setName(String name);
Collection getMembers();
void setMembers(Collection members);
}
public interface Employee {
int getId();
void setId(int id);
String getName();
void setName(String name);
}
When i setup the mapping as follows:
<hibernate-mapping>
<class
name="EmployeeImpl"
table="EMPLOYEE"
proxy="Employee"
dynamic-update="false"
dynamic-insert="false"
mutable="true"
> ... </class>
<class
name="ProjectImpl"
table="PROJECT"
proxy="Project"
dynamic-update="false"
dynamic-insert="false"
mutable="true"
>
<id
name="id"
column="ID"
type="int"
unsaved-value="-1"
>
<generator class="hilo">
</generator>
</id>
...
<set
name="members"
table="PROJECT_MEMBERS"
lazy="false"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="PROJECT_ID"
>
</key>
<many-to-many
class="Employee"
column="EMPLOYEE_ID"
outer-join="auto"
/>
</set>
...
</class>
</hibernate-mapping>
I get a failure that there is no persistor for the "Employee" class.
Shouldn't hibernate be aware that there's a persistor who's proxy
class is "Employee", and use the "EmployeeImpl" as the implementation class?
We're going to be developing components which have these types of
relationships, and component1 shouldn't know the implemenation classes of component2, and should only talk through interfaces, helpers, and factories.
But I can't figure out a way to get hibernate to support this.
And in general, I'm not able to store the collection even if I just use
implementation classes. I keep getting a ClassCastException when i try to save the Project object.
java.lang.ClassCastException
at net.sf.hibernate.type.SetType.wrap(SetType.java:24)
at net.sf.hibernate.impl.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:78)
at net.sf.hibernate.impl.WrapVisitor.processCollection(WrapVisitor.java:49)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.WrapVisitor.processValues(WrapVisitor.java:93)
|