Hi All
This is a strange sort of a question and I have one way around it however I was wondering what the best practice would be (not that this situation would be likely to occur in practice).
I have a JPA entity which has a field of type Calendar. However the accessor for this field (and the column of the table in which it is stored) returns an integer representing the year the calendar holds. Problem is, a build error occurs if the accessor is not annotated with Temporal (as the field itself is a temporal type), but the accessor is not actually returning a temporal type but an int.
Heres a simple illustration:
private Calendar yearOfRelease = Calendar.getInstance();
public int getYearOfRelease() { return yearOfRelease.get(Calendar.YEAR); }
public void setYearOfRelease(int yearOfRelease) { this.yearOfRelease.set(Calendar.YEAR, yearOfRelease); }
I can work around this by changing the name of the field to something which does not match the accessor name e.g. yearReleased, but this just feels like a hack.
Any help greatly appreciated.
Simon
[Message sent by forum member 'simonmfox' (simonmfox)]
http://forums.java.net/jive/thread.jspa?messageID=276581