0

How to use timebox with hibernate to save to mysql?

asked 2013-01-14 07:42:54 +0800

ntsetso gravatar image ntsetso
59 1 4

Hi,

In the corresponding class, to save date picked from datebox and time from timebox I have the following code:

@Temporal(TemporalType.DATE)
private Date startDate;

@Temporal(TemporalType.TIMESTAMP)
private Date startTime;

The startDate saves correctly but startTime returns null. I can't find the way to pick the time from timebox and map to mysql.

TIA
ntsetso

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-01-15 04:38:52 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Try same with 6.0.4

link publish delete flag offensive edit
0

answered 2013-01-14 22:39:05 +0800

ntsetso gravatar image ntsetso
59 1 4

updated 2013-01-14 23:01:12 +0800

Thanks for replying
I worked a small example following your suggestion.
The model looks like

[ ... ]
@Entity
@Table(name = "workshop")
public class Workshop {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	private Date startDate;
	@Column(columnDefinition = "time")
	private Timestamp startTime;
	@Column(columnDefinition = "time")
	private Timestamp closeTime;
[ ... ]

and in ZUL page

[ ... ]
Date:  <datebox value="@bind(varEvt.startDate)" format="dd-MM-yyyy" ></datebox>

Start:  <timebox value="@bind(varEvt.startTime)" format="HH:mm" ></timebox>

Close:  <timebox value="@bind(varEvt.closeTime)" format="HH:mm" ></timebox>
[ ... ]

The data now saves correctly in mysql

+----+------------+-----------+-----------+
| id | startdate  | starttime | closetime |
+----+------------+-----------+-----------+
|  1 | 2013-01-31 | 07:00:00  | 08:30:00  |
+----+------------+-----------+-----------+
1 row in set (0.00 sec)
mysql>

I was using ZK 6.0.0 and it returned "error converting java.util.Date to java.sql.Timestamp". I changed to
ZK 6.0.1. and then It worked.

The full example can be found at http://muchanga.net/zk/timetest.war

link publish delete flag offensive edit
0

answered 2013-01-14 08:06:11 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

I will suggest you use binding with TimeStamp class something like this

In Your View Model

private Timestamp scheduledStartDate;// Add get/set methods

and in ZUL page

<timebox cols="20" format="a hh:mm:ss" value="@bind(vm.scheduledStartDate)"/>


I Just tested everything worked fine for me

i got this result.

2013-01-14 02:32:30.0

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2013-01-14 07:42:54 +0800

Seen: 50 times

Last updated: Jan 15 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More