Results 1 to 3 of 3
  1. #1
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default Doubt with hibernate and date field

    I'm using hibernate to access to a Data base done with MSAccess
    The class that I am persisting has an attribute which type is "java.sql.Timestamp (its name is hExit), the type of the columns is Datetime

    I don't have problems to save it.
    The problems is when I want to access to the records filtering the date
    I tried using the "criteria" that provide the API of hibernate, but it gives to me all of record or none

    can you help me?

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default

    I would change the attributes to a Calendar type .
    the mapping would be something like that:
    Java Code:
    <property name="date" type="calendar" column="finishdate"/>
    Java Code:
    Query query = getSession().createQuery(select .... where (req.date between :date1 and :date2)
    .setCalendar("date1 ",this.getYear()[0])
    .setCalendar("date2",this.getYear()[1]);

  3. #3
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default

    Active " show_sql " and check the SQL query that is sending you.
    Maybe Access doesn't support "< >,between dates" and so on.
    search on internet this.

Similar Threads

  1. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM
  2. Hibernate doubt
    By Peter in forum JDBC
    Replies: 2
    Last Post: 07-04-2007, 02:41 PM
  3. Replies: 2
    Last Post: 06-30-2007, 04:01 PM
  4. problem with date field
    By Ed in forum JDBC
    Replies: 2
    Last Post: 06-12-2007, 05:27 PM
  5. Final field question
    By derrickD in forum Advanced Java
    Replies: 1
    Last Post: 04-28-2007, 11:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •