Hi! I get an EntityNotFoundException from the EntityManager.find()-Method. I've the following DB structure:
:
Table "Order":
-id
-myClassId
Table "MyClasses":
-id
My POJOs look like:
Order
{
int id;
MyClass myClass;
}
MyClass
{
int id;
}
In case when no MyClass is defined for an Order, the field myClassId hat the Integer value 0 (not NULL).
When calling the find()-method Hibernate finds an order which has no MyClass difined (myClassId has the value 0). Hibernate tries to find a MyClass in the table MyClasses, finds nothing and throws an EntityNotFoundException. But I want to get an Order object with a null pointer in the variable myClass in such cases.
Which ways are there to achieve that? Thank you!
|