Hello,
I am using annotations to map a basic collection of Strings to an existing entity like this:
Inside the parent entity class:
@org.hibernate.annotations.CollectionOfElements
@JoinTable (name="GoalToAchieve_entry", joinColumns=@JoinColumn(name="goalToAchieve_id"))
@org.hibernate.annotations.Sort(type = org.hibernate.annotations.SortType.NATURAL)
private SortedSet<String> entries = new TreeSet<String>();
This works fine and I have a 2-column (goalToAchieve_id and element) table resulting from the join. So I was wondering, how can I add a date/time stamp (auto-generated by MySQL) to each String of the collection, so that i can display a 3rd column with a time stamp every time a new String is added to the collection? The objective is to use a collection of simple objects (Strings) and not have to create a whole new entity (with a time/date field).
Is there a recommended way to do that? I believe even if I provide a timstamp field at the jsp interface which handles the adding of new Strings to the collection, it would still be a hibernate issue, since I need the timestamp to be persisted on the db.
Thanks in advance for any help.
Kindest regards