I'm not understanding whether the find() method return null if the id is not found in the table. In the documentation doesn't say anything. Let consider this code where the username is the primary key in the table
public boolean isUserInDb(String username)
{
boolean isPresent = false;
if(em.find(UserCredential.class, username) != null)
{
isPresent = true;
}
return isPresent;
}
could it work?
The spec says it will return null if the entity was not found. It should work.
Documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With