英文:
is there any function in jpa to find customer by its firstName
问题
我想使用JPA内置查询从数据库中获取记录,我想根据客户的名字获取客户,是否有像下面的示例一样的方法可用?
Customer findByfirst-name(String name); // 我尝试过
但是没有找到最佳解决方案,我想根据客户的FirstName获取响应。
英文:
I want to fetch the record from the database by using JPA base in built query I want to fetch the customer by its first Name so is there any method like below example available?
Customer findByfirst-name(String name); // I tried it
but not found the best solutions I want to get the response as per FirstName of Customer
答案1
得分: 1
你可以在你的存储库接口中使用特定的命名约定定义一个方法,以使用Spring Data JPA按照客户的名字查找客户。以下是如何做到这一点的示例,假设你有一个名为Customer的实体类,其中有一个名为firstName的字段:
Customer findByFirstName(String firstName);
英文:
You may define a method in your repository interface with a particular naming convention to find a customer by their first name using Spring Data JPA. Here's an example of how to do this, assuming you have an entity class named Customer with a field called firstName:
Customer findByFirstName(String firstName);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论