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

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -