作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 spring 数据 JPA 1.8.2 并试图获得最佳结果。我正在使用以下方法
LearningSession findTopBySourceAndExternalLmsSessionIdAndCourseCodeAndLearnerEnrollmentEnrollmentStatusOrderByIdAsc(String source, String externalLmsSessionId, String courseCode, String enrollmentStatus);
LearningSession findTopBySourceAndExternalLmsSessionIdAndCourseCodeAndLearnerEnrollmentEnrollmentStatus(String source, String externalLmsSessionId, String courseCode, String enrollmentStatus);
*
每件事。到底要下单
order by learningse0_.id asc
select TOP ? learningse0_.*
from LearningSession learningse0_
left outer join LearnerEnrollment learnerenr1_ on learningse0_.ENROLLMENT_ID=learnerenr1_.id
where learningse0_.source=?
and learningse0_.externalLmsSessionId=?
and learningse0_.courseCode=?
and learnerenr1_.enrollmentStatus=?
Hibernate: select TOP ? learningse0_.id as id1_47_, learningse0_.brandName as brandNam2_47_, learningse0_.courseApprovalId as courseAp3_47_, learningse0_.courseCode as courseCo4_47_, learningse0_.endTime as endTime5_47_, learningse0_.externalLmsSessionId as external6_47_, learningse0_.externalLmsUrl as external7_47_, learningse0_.isCourseMessageDisplay as isCourse8_47_, learningse0_.LANGUAGE_ID as LANGUAG15_47_, learningse0_.LEARNER_ID as LEARNER16_47_, learningse0_.ENROLLMENT_ID as ENROLLM17_47_, learningse0_.learningSessionGuid as learning9_47_, learningse0_.lmsProvider as lmsProv10_47_, learningse0_.redirectUrl as redirec11_47_, learningse0_.source as source12_47_, learningse0_.startTime as startTi13_47_, learningse0_.uniqueUserGuid as uniqueU14_47_ from LearningSession learningse0_ left outer join LearnerEnrollment learnerenr1_ on learningse0_.ENROLLMENT_ID=learnerenr1_.id where learningse0_.source=? and learningse0_.externalLmsSessionId=? and learningse0_.courseCode=? and learnerenr1_.enrollmentStatus=? order by learningse0_.id asc
13:53:47.686 [main] DEBUG org.hibernate.engine.jdbc.spi.SqlExceptionHelper - could not extract ResultSet [n/a]
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) ~[sqljdbc4-4.0.jar:?]
First
,
Top1
,
First1
但结果是错误。请帮忙。
最佳答案
不确定这是否适合您,但我遇到了同样的错误,经过大量挖掘后,我发现我在 JpaVendorAdapter 中使用了 SqlServerDialect,当我将其更改为更专门用于 SqlServer2012 (SqlServerDialect2012) 时,错误走了:
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="SQL_SERVER" />
<property name="databasePlatform" value="org.hibernate.dialect.SQLServer2012Dialect" />
<property name="showSql" value="true" />
</bean>
关于sql-server-2012 - Spring 数据 Jpa findTop 和 findFirst 生成错误 '@P0' 附近的语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32453649/
我使用 Spring JPA,当我使用“findTop”关键字时会抛出 NonUniqueResultException Java 源代码: Optional findTopByXXXOrderByI
我想知道是否可以将参数传递给 jpa 数据方法 @Entity public class Employee { private @Id @GeneratedValue Long id; private
我最近开始使用 Spring data jpa。 如果有人能阐明 技术差异 Spring Data JPA findFirst 和 findTop。 区别,用法。 谢谢 最佳答案 来自 Spring
我正在使用 spring 数据 JPA 1.8.2 并试图获得最佳结果。我正在使用以下方法 LearningSession findTopBySourceAndExternalLmsSessionId
我是一名优秀的程序员,十分优秀!