-->
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: MySQL Time and h:selectOneMenu
PostPosted: Thu Nov 08, 2007 8:59 am 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
I have an entity with a field 'openTime' that is a MySQL TIME datatype. Hibernate has generated this as an entity field as such:
Code:
   @Temporal(TemporalType.TIME)
   @Column(name = "OPEN_TIME", length = 0)
   public Date getOpenTime() {
      return this.openTime;
   }   
I need to allow a user to enter a time on the page. Instead of allowing free text I am using an h:selectOneMenu and a list of times on the half hour (eg. "00:00", "00:30", etc). I can select a time from the list and it will save it in the database. However when I go to edit the record, the select list is not able to select the value that was already saved (ie. set one of the OPTIONs to selected="true").

I ran this through the debugger and the problem is that the com.sun.facces.renderkit.html_basic.MenuRenderer cannot convert from java.util.Date to java.sql.Time. The error produced (and swallowed on line 537) is:
Code:
Cannot convert 1/1/70 7:00 AM of type class java.util.Date to class java.sql.Time
What is my best option here? Should I go for a custom converter (I haven't done one yet) rather than s:convertDateTime? Or is there an Hibernate option I can set on the entity definition (maybe 'columnDefinition' on @Column)?

Any advice is very much appreciated.

Thanks,

Damian.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 16, 2007 5:34 am 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
Can anyone offer a suggestion here?

Is java.sql.Time the default for Hibernate? I don't use it in my code anywhere. Is it created from the TemporalType.TIME?

Thanks,

Damian.


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.