What I am trying to do is create a Pojo that has the majority
of its Getters/Setters mapped to a a column in the table,
The table is then fully mapped but I also leave two gettings and setters un-mapped.
These un-mapped fields will be given values later just before the class is sent to the view to be displayed on the web page.
I only want to store a long value of a date in Milliseonds.
Then in the controller convert it to a real date and store it in that
object of this Class. I just want to keep all the data together
but not have to store the string value in the database.
Code:
@Entity
@Table(name = "date_info", catalog = "dates")
public class DateInfo implements java.io.Serializable {
private Integer id;
private long dateStart;
private long dateEnd;
private String dateStartString;
private String dateEndString;
public DateInfo() {
}
public DateInfo(long dateStart, long dateEnd, String dateStartString, String dateEndString) {
this.dateStart = dateStart;
this.datrEnd = dateEnd;
this.dateStartString = dateStartString;
this.dateEndString = dateEndString;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "DT_START", nullable = false)
public long getDateStart() {
return this.dateStart;
}
public void setDateStart(long dateStart) {
this.dateStart = dateStart;
}
@Column(name = "DT_END", nullable = false)
public long getDateEnd() {
return this.dateEnd;
}
public void setDateEnd(long dateEnd) {
this.dateEnd = dateEnd;
}
//Don't want to map these fields as I will be filling them in later
//When i am manipulating data. I don't need to store these,
//Only keep them within this class so i can use them in the returned view.
public String getDateStartString() {
return this.dateStartString;
}
public void setDateStartString(String dateStartString) {
this.dateStartString = dateStartString;
}
public String getDateEndString() {
return this.dateEndString;
}
public void setDateEnd(String dateEndString) {
this.dateEndString = dateEndString;
}
Any ideas?
Is there anyway i can leave a Column mapping blank? or Declare it
not mapped to anything and ignore the getter and setter?
Thanks