如何创建 spring 数据查询 if where 条件用于内部对象的属性
how to create spring data query if where conditions for internal Object's properies
我已经使用 findBy
创建了 spring 数据查询
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalse(String username);
以上方法运行良好。
现在,如果在我当前对象 TaskEntity
的另一个对象中有 private GroupEntity group
,那么上面的查询将如何?
我想在上面的查询中添加 groupId 条件。
喜欢
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalseAndGroup.id(String username,String groupId);
.
Group.id
感谢您的帮助
根据Spring Doc试试这个:
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalseAndGroupId
(String username,String groupId);
Assume a Person has an Address with a ZipCode. In that case a method
name of
List<Person> findByAddressZipCode(ZipCode zipCode);
creates the
property traversal x.address.zipCode. The resolution algorithm starts
with interpreting the entire part (AddressZipCode) as the property and
checks the domain class for a property with that name (uncapitalized). If the algorithm succeeds it uses that property. If not, the algorithm splits up the source at the camel case parts from the right side into a head and a tail and tries to find the corresponding property, in our example, AddressZip and Code....
我已经使用 findBy
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalse(String username);
以上方法运行良好。
现在,如果在我当前对象 TaskEntity
的另一个对象中有 private GroupEntity group
,那么上面的查询将如何?
我想在上面的查询中添加 groupId 条件。 喜欢
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalseAndGroup.id(String username,String groupId);
.
Group.id
感谢您的帮助
根据Spring Doc试试这个:
List<TaskEntity> findByUsernameOrUsernameIsNullAndDeletedIsFalseAndGroupId
(String username,String groupId);
Assume a Person has an Address with a ZipCode. In that case a method name of
List<Person> findByAddressZipCode(ZipCode zipCode);
creates the property traversal x.address.zipCode. The resolution algorithm starts with interpreting the entire part (AddressZipCode) as the property and checks the domain class for a property with that name (uncapitalized). If the algorithm succeeds it uses that property. If not, the algorithm splits up the source at the camel case parts from the right side into a head and a tail and tries to find the corresponding property, in our example, AddressZip and Code....