1

I have an entity with a date field (java.util.Date). Normally the date is saved as for example 2012-10-19 21:29:03.000. My database is MySQL.

Now I need to query the database, through JPQL, using strictly the date portion, i.e., 2012-10-19. How would I do that?

1 Answer 1

1

That can be done by giving TemporalType when setting parameter:

Date param ... Query q = em.createQuery("SELECT a FROM EntityA a WHERE a.someDate > :param"); q.setParameter("param", param, TemporalType.DATE); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.