I have a DSL Java object, i.e. a POJO which returns this
in setters plus the getters/setters have an unusual naming pattern:
public class Demo {
private long id;
private String name;
private Date created;
public Demo id (long value) { id = value; return this; }
public String id () { return id; }
public Demo name (String value) { name = value; return this; }
public String name () { return name; }
public Demo created (Date value) { created = value; return this; }
public Date created () {
if (created == null) created = new Date ();
return created;
}
}
Is it possible to tell JPA to use "name(String)" and "name()" as the setter/getter method?
[EDIT] My issue is the created
field above. For this field, I want JPA to use the "getter" created()
so the field will always be non-NULL.
Or is there a way to tell JPA to use CURRENT TIMESTAMP
when creating a new object with created == null
?