简体   繁体   中英

Eclipselink - JPA 2.0 - Select with lockMode and maxResult doesn't work

@Override
public List<Sample> getSampleRecords() {
    List<Sample> samples = null;
    try {

        Query query = entityManager
                .createQuery(
                        "from Sample s order by s.createdAt desc")
                .setLockMode(LockModeType.PESSIMISTIC_WRITE);
         query.setMaxResults(100);
        samples = query.getResultList();
    } catch (Exception exceptionGetSample) {
        logger.error("Exception while retrieving the records", exceptionGetSample);

    }
    return samples;
}

When I executed it with oracle db an error occur :

Caused by: org.eclipse.persistence.exceptions.DatabaseException:
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
  1. If I executed it only with lockmode parameter no error occurred.
  2. If I executed it only with maxResult parameter no error occured.

I have used the eclipselink 2.5.0 library.

Please suggest some way so that I can use both the locking as well as can limit the records by using setMaxResults.

请参阅下面的链接以快速解决问题https://bugs.eclipse.org/bugs/show_bug.cgi?id=453208#c7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM