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) List findByLastName(String lastName) 

2) List findByIdOrName(Integer id, String name) 

3) List findByFirstName(String firstName) 

4) List findByAgeBetween(Integer startAge AND Integer endAge) waiting for your answer 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!