-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Interfaces and Proxies
PostPosted: Tue Jul 06, 2004 4:17 pm 
Beginner
Beginner

Joined: Thu May 27, 2004 3:07 pm
Posts: 20
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.