Question: Custom Query Methods Consider the following code snippet that defines a Person entity class mapped with the Person table in the database. Based on this
Custom Query Methods
Consider the following code snippet that defines a Person entity class mapped with the Person table in the database. Based on this snippet, answer the questions given below.
@Entity public class Person { @Id @GeneratedValue private Integer id; private String firstName; private String lastName; private Integer age; //getters and setters; } Which of the following are valid custom query methods that can be declared for this Entity class? (Note: More than one option may be correct.)
Hints:
- Let's say there is no field with the attribute name 'X' in the Person class. Then, the method's declaration findByX is invalid.
- Is the method declaration List
findByField(Integer entity1 AND Integer entity2) correct or List findByField(Integer entity1, Integer entity2) correct?
1) ListfindByLastName(String lastName)
2) ListfindByIdOrName(Integer id, String name)
3) ListfindByFirstName(String firstName)
4) ListfindByAgeBetween(Integer startAge AND Integer endAge) waiting for your answer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
