I am creating a simple Java EE web application.
Among other entities, I have the User entity, which owns some Unit objects. The entitie classes are build correctly and the user has a one to many relationship with the unit objects. I want to retrieve a list with all the Units of the logged in user.
Therefore in the unit EJB I must have the following method
public List<Unit> findUnitsByOwner(User user)
I am very unfamiliar with the persistence api and I am not being able to create a query which would retrieve the units that belong to a certain user.
Can someone help with the method body please?
Well the query is very easy :
But you could also do the easier