persistence@glassfish.java.net

RE: Problem with TemporalType.DATE

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

I make an error in code so don’t answer.

 

  _____

De : Laurent Yhuel [mailto:laurent.yhuel_at_apologic.fr]
Envoyé : mercredi 10 octobre 2007 20:24
À : persistence_at_glassfish.dev.java.net
Objet : Problem with TemporalType.DATE

 

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