-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Date is being truncated when using HQL Update Command
PostPosted: Thu Oct 22, 2009 8:50 pm 
Newbie

Joined: Thu Oct 22, 2009 8:31 pm
Posts: 2
The following code works except that when I fetch the data and look at it in the eclipse debugger, I see that the hours, minutes, seconds have been zeroed for my lastUpdatedDate field.

When I check the value "recent" the hours, minutes and seconds are definitely non-zero!

Can someone tell me how to preserve these values?
Thanks,
Siegfried

Code:
        Calendar recent = Calendar.getInstance();
        recent.setTime(IN_RANGE_RECENT);
        Session session = sessionFactory.openSession();
        session.createQuery("update BacklogOrder set lastUpdatedDate = :recent, customerId = :custId where orderId=:orderId")
        .setCalendarDate("recent",recent)
        .setString("orderId", "order")
        .setString("custId", "siegfried")
        .executeUpdate();
        session.flush();
        session.close();
        List<BacklogOrder> bList = tstBacklogDao.getBacklogOrdersBetweenDates(END_RANGE, BEGIN_RANGE);


Here is the entity:

Code:
/**
*
*/
package cashback.entities;

@Entity
@Table(name="CASHBACK_ORDER_BACKLOG")

public class BacklogOrder {

....
    private String orderId;
    private String customerId;
    private String marketplaceId;
    private Date orderDate;
    private BacklogStatus state;
    protected Date lastUpdatedDate;   
    /**
     * Gets the updated date.
     *
     * @return the last updated date
     */
    @Column(name="last_updated", nullable=true, updatable=false)
    public Date getLastUpdatedDate() {
        return lastUpdatedDate ;
    }   
    /**
     * Sets the order date.
     *
     * @param orderDate the new order date
     */
    protected void setLastUpdatedDate(Date lastUpdatedDate) {
        this.lastUpdatedDate = lastUpdatedDate;
    }
}



Top
 Profile  
 
 Post subject: Re: Date is being truncated when using HQL Update Command
PostPosted: Fri Oct 23, 2009 4:13 pm 
Newbie

Joined: Thu Oct 22, 2009 8:31 pm
Posts: 2
I figured it out with regard to the setCalendarDate function. This is the wrong function.

So is setDate. So is setTime. I finally figured out that setTimeStamp is the function. Ironically, setTimestamp accepts a java.util.Date! Not what I expected!

Also: I cannot log in using my original account. Maybe it has been too long since I participated in the forum? The FAQ says to contact a board (or bored?) member? How do I do that? I would like to use my original account because that is associated with the email address I ready daily.

Also: My original account was my home account. I tried to create a new account using my new work email address and accidentally claimed I was under 18 years old! Ooops! I tried to go back and use my work account again but the web site was convinced I was too young.

I finally created this account using an alternative email account I don't check often.

Thanks,
Siegfried


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.