null entity from left join using sqlResultSetMapping - is it possible
Hi, i have an namedNativeQuery which consists of a left join across 2 managed entities using a resultSetMapping. All is fine, except that the query by design sometimes doesn't match on the second entity and returns null. Is it possible to handle this using JPA?
The problem i have is that if i use a resultSetMapping, i get an error that the primary key of the second entity is null, as all fields from the query for the second entity are null.
Is it possible to have JPA create an empty/null entity object in this instance?
I can force the primary key of the entity to have a value (if it is null, i create the entity so i know what value to use, it isn't just random) but i'm worried this will pollute the cache and not be persisted correctly when i come to create the object as the entity doesn't actually exist in the db.