Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
The following example show you how to using System.currentTimeMillis() Java function to assign unique value to entity key which in following class is ( Long id ) .
@Entity @Table(name="TOPIC") public class topic { @Id private long Id=System.currentTimeMillis(); private String title; private Date creationDate; private Date modifedDate; private String content;
public long getId() { return Id; } public void setId(long id) { Id = id; }
@Column(name="TITLE") public String getTitle() { return title; } public void setTitle(String title) { this.title = title; }
@Column(name="CREATION_DATE") public Date getCreationDate() { return creationDate; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; }
@Column(name="MODIFED_DATE") public Date getModifedDate() { return modifedDate; } public void setModifedDate(Date modifedDate) { this.modifedDate = modifedDate; }
@Column(name="CONTENT") public String getContent() { return content; } public void setContent(String content) { this.content = content; } }
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )