How to set Date value as parameter in filter to Hibernate Query?

  • Vijayakumar

    Vijayakumar - 2013-05-10

    In OX4.7 how to set Date value as parameter in filter condition to Hibernate Query?
    I'm using MySql server.

    In liferay6.1.1 it throws an error "Parameter value [2012-08-13] did not match expected type [java.util.Date]" as i'm setting the value as String datatype. It throws an error eventhough the datatype in java.util.Date .

    Thanks in advance.

  • Javier Paniza

    Javier Paniza - 2013-05-13

    Hi Vijayakumar,

    you must send to your query the parameter of the correct type, so if the parameter is a date you have to send a date.

    To create a date if the value comes the user, some file, other process, etc. just use DateFormat to convert the String in Date. On the other hand, if you need to use a specific date in code use the Dates utility included in OpenXava to create the Date objects.

    This is a generic JPA/Hibernate question, not specific of OpenXava.

    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.


Log in to post a comment.