Q:

Named Query to delete a record by Supplying the entire object

Hi I want to delete a record from the table spt_tutorials by giving an object of its entityClass SptTutorials .I am writing the named query like this.
@NamedQuery(name = "SptTutorials.deleteVideo", query = "DELETE s FROM SptTutorials s WHERE s.SptTutorials = :SptTutorials")})

where SptTutorials is the entity class and the parameter that I am passing thru the WHERE clause is a SptTutorials object.Is this query correct.

A:

As "SptTutorials" is not a field in SptTutorials then fix your query. "s.SptTutorials" means field "SptTutorials" of the object "s" (which is of type SptTutorials). Perhaps
DELETE FROM SptTutorials s WHERE s = :param

or
DELETE FROM SptTutorials s WHERE s.id = :id

Where "id" is the identity(field) of the SptTutorials object to be deleted.
All of that can be seen in a quick read of the JPA spec, or any of the many JPA docs online

