I have BaseEntity and i want to set some property in all hibernate add and update ,for do this request we can do that with this code 




public abstract class BaseEntity<T> implements Serializable {


private static final long serialVersionUID = 4295229462159851306L;



@GeneratedValue(strategy = GenerationType.IDENTITY)

private T id;


@Column(name = "version")

private Integer version;



@ManyToOne(fetch = FetchType.LAZY)

@JoinColumn(name = "createdby", updatable = false)

private User createdBy;



@ManyToOne(fetch = FetchType.LAZY)

@JoinColumn(name = "updatedby")

private User updatedBy;


@Column(name = "createddate", updatable = false)

private Date createdDate = new Date();


@Column(name = "updateddate")

private Date updatedDate = new Date();


@Column(name = "ip")

private String ip = "";







public class BaseEntityListener {




private void initializeCreatedAt(BaseEntity baseEntity) {





baseEntity.setCreatedDate(new Date());

baseEntity.setUpdatedDate(new Date());


in hibernate 5 EntityListeners dose not work