persistence@glassfish.java.net

Problem with TemporalType.DATE

From: Laurent Yhuel <laurent.yhuel_at_apologic.fr>
Date: Wed, 10 Oct 2007 20:24:03 +0200

Bonjour

I use reverse engineering from Hibernate Tools on database postgres.

I have got a problem with field type date.

The generated class

 

 @Temporal(TemporalType.DATE)
    @Column(name="zd_datedebut", nullable=false, length=13)
    public Date getZdDatedebut() {
        return this.zdDatedebut;
    }

 

I don't understand the param length=13. I think in SQL date field write
2007-10-10 so the length is 10

 

Request in java look like this :

 

EntityManager em = [...]
String sql = "select l from TZonedetail l where l.zdDatedebut = :chp";
Calendar cal = Calendar.getInstance();
Query q = em.createQuery(sql);
q.setParameter("chp",cal, TemporalType.DATE);
List lst =retour = q.getResultList();


If I have a record with date of day it doesn't retrieve it.

 

Thanks for your help

Laurent