2015-07-13 145 views
1

我想写的东西是这样的:请帮我写春天的数据JPA

find where player id = ?1 && (lastspinneddate < ?2 || lastspinneddate == null) 

,但是当我写这样的:

repo.findByPlayerIdAndLastSpinnedDateBeforeOrLastSpinnedDateIsNull(playerId,startOfDay); 

,但是这是不正确的像这样回来:

find where (player id = ?1 && lastspinneddate < ?2) || lastspinneddate == null 

请帮我写上面的spring数据jpa,在此先感谢

+0

做了你走进一看QueryDSL或API规范标注方法? –

回答

1

只是像

@Query("select p from Player p where p.id = ?1 && (p.lastSpinnedDate < ?2 or p.lastSpinnedDate is null)") 
+0

感谢您的回复,但是我们无法写作@Query,我想知道弹簧数据jpa有多强大且灵活吗? – ratnesh

+0

自动查询生成适用于非常简单的情况。它不应该尽可能避免尽可能多的手工查询。方法的可怕名称本身就意味着你应该指定一个查询。 –

+0

如何在@Query中检查null,其说法意外的令牌“null” – ratnesh