UpdateTimestamp on relation tables

is there a way to get the creation date or modification date into an implicitly generated relation table?

so if i have a @ManyToMany List<Other> others; a relation table like main_entity_others will be generated with columns: main_identifier, other_identifier

I would also like to have an additional column creation_date, how would one achieve that (without explicitly defining the relation table as an entity with two ManyToOne attributes because then i would need handle the inserts myself…)

You wouldn’t need to handle inserts yourself. You can just cascade all operations to achieve automatic maintenance.

so where do i specify the creation date column?

Create a separate entity and define the column there. When you use @ManyToMany(cascade = ALL), you don’t have to take care of about inserts.

So the only option IS to create the explicit entity for the relation table?
That’s what I was trying to avoid

So instead of:

List<Other> others

I would have an additional class:

// omitted IdClass for this example
class BaseEntityOther {
  BaseEntity base;

  Other other;

List<BaseEntityOther> others;

This creates much more overhead and is less intuitive in queries if one is used to the HQL style.

Hibernate ORM has no way of maintaining such a column if you don’t have an entity that defines it. You can of course create a database trigger that maintains such a column.