java jpa set_JavasetMaxResults用于Spring-Data-JPA注释?

我正在尝试将Spring-Data-JPA合并到我的项目中。让我困惑的一件事是如何通过注释实现setMaxResults(n)?

例如,我的代码:

public interface UserRepository extends CrudRepository

{

@Query(value="From User u where u.otherObj = ?1 ")

public User findByOhterObj(OtherObj otherObj);

}

我只需one (and only one)要从otherObj 返回User,但找不到任何方法来注释maxResults。有人可以给我提示吗?

(mysql抱怨:

com.mysql.jdbc.JDBC4PreparedStatement@5add5415: select user0_.id as id100_, user0_.created as created100_ from User user0_ where user0_.id=2 limit ** NOT SPECIFIED **

WARN util.JDBCExceptionReporter - SQL Error: 0, SQLState: 07001

ERROR util.JDBCExceptionReporter - No value specified for parameter 2

)

我找到了一个链接:https : //jira.springsource.org/browse/DATAJPA-147,我尝试但失败了。现在看来不可能了吗?为什么这么重要的功能没有内置在Spring-Data中?

如果我手动实现此功能:

public class UserRepositoryImpl implements UserRepository

我必须在中实现大量的预定义方法CrudRepository,这将是可怕的。

环境:spring-3.1,spring-data-jpa-1.0.3.RELEASE.jar,spring-data-commons-core-1.1.0.RELEASE.jar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值