Hi all,
i have a OneToMany relationship in an @Entitiy
Code:
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
@JoinColumn(name="transaction_id")
private Set<MyData> myData= new HashSet<MyData>();
When i want to read this HashSet with:
Code:
myData= (HashSet<MyData>) MyData.getMyData();
i'm getting following exception:
java.lang.ClassCastException: java.util.HashSet cannot be cast to org.hibernate.collection.PersistentSet
i could use
Code:
PersistentSet persSet = (PersistentSet)myData.getMyData();
if (myData.wasInitialized()) {
myData.addAll(persSet);
}
but i dont want to use hibernate classes in my code because i want to use pure JPA.
Does anyone have an idea why i have to cast and how to avoid this situation
thank you very much