Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » LocalDateTime is not mapped correctly(LocalDateTime is not mapped correctly in criteriaquery with isTrue)
LocalDateTime is not mapped correctly [message #1807600] Tue, 04 June 2019 13:07 Go to next message
Jeno Tobak is currently offline Jeno TobakFriend
Messages: 2
Registered: June 2017
Junior Member
public class MyEntity {
@Id
Long id;
String name;
LocalDateTime date;
...
}

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<MyEntity> cq = cb.createQuery(MyEntity.class);
Root<MyEntity> root = cq.from(MyEntity.class);

cq.where(cb.and(cb.isTrue(cb.literal(Boolean.TRUE)), cb.lessThan(root.get("date"), LocalDateTime.now().plus(1l, ChronoUnit.DAYS))));

List<MyEntity> results = em.createQuery(cq).getResultList();

throws
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.4.v20190115-ad5b7c6b2a): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "SELECT ID, DATE, NAME FROM MYENTITY WHERE ((1 = 1) AND (DATE < 2019-06-05T14[*]:53:19.153))"; expected "[, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, ILIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ,, )"; SQL statement:
SELECT ID, DATE, NAME FROM MYENTITY WHERE ((1 = 1) AND (DATE < 2019-06-05T14:53:19.153)) [42001-199]
Error Code: 42001

Tested with H2 and DB2 databases.
Hibernate works well.
cq.where(cb.lessThan(root.get("date"), LocalDateTime.now().plus(1l, ChronoUnit.DAYS)));
or
cq.where(cb.isTrue(cb.literal(Boolean.TRUE)));
works too
Re: LocalDateTime is not mapped correctly [message #1820713 is a reply to message #1807600] Mon, 27 January 2020 14:01 Go to previous message
Jeno Tobak is currently offline Jeno TobakFriend
Messages: 2
Registered: June 2017
Junior Member
with "EclipseLink, version: Eclipse Persistence Services - 2.7.5.v20191016-ea124dd158" it works fine
Previous Topic:NPE on a JPQL query with NULL arg: bug?
Next Topic:Eclipselink library failed to build(version 2.7.5). please help.
Goto Forum:
  


Current Time: Wed Jun 03 04:36:12 GMT 2020

Powered by FUDForum. Page generated in 0.03165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top