Hi everybody,
Im workin on
Hibernate version: 3.2.4 (from JBoss 4.2.2.GA)
and I have some problem configuring my entities.
This is my code:
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Party
@Entity
public class Person extends Party
@Entity
public class Doctor {
@ManyToOne(cascade={CascadeType.ALL}, fetch = FetchType.EAGER)
public Party getParty()
}
With this configuration, when i do this:
Code:
Person pers = (Person) doctor.getParty();
everithing is ok!
But when i set party fechtype as LAZY an error occurred:
java.lang.ClassCastException: mypackage.Party_$$_javassist_104By now I found a workarround to set it LAZY anyway:
instead of this:
Code:
Person pers = (Person) doctor.getParty();
i do this:
Code:
Party party= doctor.getParty();
Person pers = (Person) entityManager.find(Person.class, party.getId());
even if the consequence is this:
WARN [ProxyWarnLog] Narrowing proxy to class myPackage.Person - this operation breaks ==Can anyone tell me how can I set getParty LAZY and cast without any problem?
Code:
Person pers = (Person) doctor.getParty();
There is anything wrong on my approach?
Any suggestion will be appreciated!
Thanks
Francesco