0

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);
}
4

1 回答 1

2

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)
于 2013-07-08T06:43:06.257 回答