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);
}
2
  • Looks more like a problem with Postgre and Timestamp column type than just Java side. Commented Jul 8, 2013 at 6:38
  • yes, I can not find a way to insert an object of type Date in a column of type timestamp Commented Jul 8, 2013 at 6:42

1 Answer 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)
Sign up to request clarification or add additional context in comments.

1 Comment

@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.