spring - Pass UserID from user session as @Column in hibernate Entity -
i have user hibernate @entity has column createdby. have user info (created by) stored in user session.
@entity public user @column(name="createdby") public createdby; } i want @createdby column should automatically read user session. dont want set using setter method.
i using spring framework hibernate.
thanks
you can use @prepersist , @preupdate annotations, @prepersist, this
@prepersist public void audit () { this.createdby = securitycontextholder.getcontext().getauthentication().getname(); } you can read more here
sorry bad english, cheers
Comments
Post a Comment