hibernate - Setting createdBy and updatedBy in JPA entities automatically -


I am working on JPA (Hibernate implementation), Spring and Stripes web app. I have several JPA institutions with the following fields for audit and query purposes:

created - User id of the person who created the unit Date created - The unit was updated - The user ID of the person who updated the last updated date was updated - The date was last updated

I am working my app So that the built and updated unit is set automatically when the unit is fixed, but I am not sure that through the logged in user's ID, from the controller class to the DAO How to reach areas without having to reach and update the areas.

Do anyone have any suggestions on how I can do this to leave the user id in full place? Note that the current user id is currently stored in the HTTP object, so my backend needs access to this data in any way ...

Thanks!

On one of these ways to pass the User ID as a reference to business income You can look at:

  • (These posts may still be relevant Even if you are not using EJB.

    I personally discourage these approaches, as I see two problems with it:

    • Test Yoga Otherwise, you will need to establish relevant data in the test.
    • Contract: Participate in the contract to use the relevant data organization but are not clearly visible in the interface.
    • < / Ul>

      UserID may look like "a whole job" in a "whole place," but I think it's cleaner.

      When the unit is formed or updated, Set date and user ID For the purpose, you can use one (perhaps you are already doing). Hope it helps ...


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -