Page 1 of 2
id for ScheduleEvent
Posted: 17 Feb 2010, 10:12
by jsfcoder
Hi
ScheduleEventImpl using following properties
private String id;
private String title;
private Date startDate;
private Date endDate;
is it possible to implement a entity class using
Long id instead of String id
Any clue?
thanks
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 11:59
by rene.guenther
Maybe it would be sufficient for you to wrap a Long id, like:
Code: Select all
private Long myId;
public Long getMyId() {
...
}
public String getId() {
if (myId == null)
return null;
else
return myId.toString();
}
?
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 12:25
by cagatay.civici
jsfcoder, any particular reason you want it to be a long. It is used internally and generated so you don't need to care about it.
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 17:42
by jsfcoder
Hi Rene,
Good idea. Thanks for your advice! I will try it out.
Hi Cagatay,
I'm using seam 2.1.2 with seam application framework.
calendarEvent.java
entity class is like following normally:
@Id @GeneratedValue
private Long id;
private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;
which id will map to database as a primary key, will be referenced by other table as foreign key, I never try using String as id
.
seam application framework have some functions like
getId()
setId(Object id)
assignId(Object id)
any advise? thanks
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 18:08
by cagatay.civici
Does your calendarEvent implement PrimeFaces ScheduleEvent?
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 18:44
by jsfcoder
@Name("calendarEvent')
public class CalendarEvent implements ScheduleEvent {
@Id @GeneratedValue
private String id;
private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;
private boolean allDay = true;
private String styleClass;
private Object data;
getter setter ....
}
maybe this way looks better ...
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 18:55
by cagatay.civici
I think it'd be better if you can use another property for database id, ScheduleEvent's id is the identifier in scheduleModel which PrimeFaces generates. So I'd go with the following;
Code: Select all
@Entity
public class CalendarEvent implements ScheduleEvent {
@Id @GeneratedValue
private Long dbId;
@Transient
private String id;
private String title;
private Date startDate;
private Date endDate;
private String content;
private String remarks;
private boolean allDay = true;
private String styleClass;
private Object data;
getter setter ....
}
Re: id for ScheduleEvent
Posted: 17 Feb 2010, 19:26
by jsfcoder
Hi Cagatay,
Sorry, I did not read the ScheduleModel carefully.
thanks for your advice!
Re: id for ScheduleEvent
Posted: 26 Feb 2010, 15:47
by jsfcoder
few new problems encounter
1) JPA1 do not support persist
private Object data;
resolve by separate entity class and scheduleEventImpl object.
and then extend ScheduleEventImpl to add-in more properties, like following
private String id;
private String title;
private Date startDate;
private Date endDate;
private boolean allDay = true;
private String styleClass;
private Object data;
private Long dbId;
private String content;
private String remarks;
display events in scheduler, no problem.
have difficult to update event,
as
p:schedule eventSelectListener is looking for ScheduleEntrySelectEvent,
ScheduleEntrySelectEvent looking for ScheduleEvent
is any work around to ? to extend ScheduleEvent to ExtendScheduleEvent
thanks
Re: id for ScheduleEvent
Posted: 27 Feb 2010, 11:32
by jsfcoder
Any idea?
thanks