I would like to persist an instance of my class into objectdb.
@Entity
public class MyClazz {
@Column(nullable = false)
DateTime date;
}
With hibernate I just need to annotate the field with an additional annotation.
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
But since I want to use objectdb I can't use these annotation, so I get an exception ("Attempt to store an instance of a non persistable type org.joda.time.DateTime")
The problem is that objectdb disables the "support" for serializable types. (see here) I'm pretty sure that they do this for a good reason so want to keep it this way.
As a workaround for now I use a pre and post hook.
@Column(nullable = false)
private Date date = new Date();
@Transient
private DateTime dateTime;
@PrePersist
private void persist() {
date = dateTime.toDate();
}
@PostLoad
private void load() {
dateTime = new DateTime(date.getTime());
}
My question: is there another way? I would like to get rid of the additional date field.