Have a class called events which is a many-to-one mapping to class location
using hibernate and spring.
when I use eventsDao.saveAll(entities); insert timestamp is created only for the first object in the list.
This is how timestamp looks in my mapping file,
<property name="insertTime" type="org.joda.time.contrib.hibernate.PersistentLocalDateTime" column="INSERTTIME"/>
How can I change it to save the insert timestamp for all the objects in the list? any suggestions please!
This is how you would do it with annotations. Not sure what the equivalent is with xml configuration. You can just create a new Date() whenever your instance is created, and then update the updated field whenever the entity gets updated:
Don’t provide a setter for any of these methods, only getters.