I am trying to use the primefaces schedule component, I found problem in inserting the date () in the database (postgresql), there is a problem of incompatibility between the date type of java and timestamp postgres that I can not seem to solve:

org.hibernate.exception.DataException nested exception is: 
ERROR: invalid input syntax for type timestamp : 
    "16:00:00.747000 +00:00:00"

here is the function I tested the insertion in the database :

@Test
public void testEdit() {
    Event event = new Event(); 
    Calendar t = (Calendar) today().clone();   
    t.set(Calendar.AM_PM, Calendar.PM);  
    t.set(Calendar.DATE, t.get(Calendar.DATE) + 4);  
    t.set(Calendar.HOUR, 4); 
    event.setStartDate(t.getTime());
    sessionService.save(event);
}
share|improve this question
    
Looks more like a problem with Postgre and Timestamp column type than just Java side. – Luiggi Mendoza Jul 8 '13 at 6:38
    
yes, I can not find a way to insert an object of type Date in a column of type timestamp – Habib Ksentini Jul 8 '13 at 6:42
up vote 2 down vote accepted

Looks like your Hibernate mappings are incorrect. You need to map the column as a temporal "timestamp" field, but it looks like your computer is sending just the time. A timestamp has a date component, but there's no date in "16:00:00.747000 +00:00:00".

You haven't shown the mapping for the entity so it's hard to be more specific. If you're using JPA2 mapping annotations you'd write:

@Temporal(TIMESTAMP)
share|improve this answer
    
@HabibKsentini Well, there's your problem. You can't store a TIME in a TIMESTAMP column. Use a TIME column in the database or use a TIMESTAMP mapping to match what's really in the database. – Craig Ringer Jul 8 '13 at 6:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.