Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8680579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:17:15+00:00 2026-06-12T21:17:15+00:00

I`m looking for an elegant way to achieve the next task: I have one

  • 0

I`m looking for an elegant way to achieve the next task:
I have one entity called Ticket which has some fields like : owner, createdTs,body…. , and also a List entity which will keep track of all changes performed on a ticket.
My app is build with Strus2, Spring 3, Jpa + Hibernate, and i have a service class TicketService which has the method save/updateTicket(Ticket ticket).
I have tried to to implement an aspect @Before save/update method but my problem is that i cannot access the old value of ticket in order to detect changes and create TicketHistory object according to these changes.
I tried the aspect approach because i access this method from many other methods and right now these objects (Ticket and TicketHistory) are tight coupled.

any idea ?
Thanks,
Adrian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:17:16+00:00Added an answer on June 12, 2026 at 9:17 pm

    Since you’re using Hibernate, there is a very nice declarative solution:

    Envers

    Envers (for En titiy Vers ions) automatically detects changes on entities annotated with @Audited and creates a history in the database. You can even add custom information to the revisions like the user who made the change.

    See the Quickstart for Envers for more information.

    The downside is that you have to change some amount of code since there will be no need for TicketHistory anymore. Older revisions of entities are accessed via the AuditReader class.

    Also note that when using Envers, your program depends directly on Hibernate, and not just JPA anymore. If you ever want to change your persistence provider (not that this happens very often), you’re gonna have some more work to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an elegant way of determining which element has the highest occurrence
I'm trying to do some number formatting and I'm looking for an elegant way
I'm looking for an elegant way, without a ton of dependencies as in some
I'm looking an elegant way to position two divs one besides the other without
I'm looking for an elegant way to return multiple values from one subtemplate. why?
I'm looking for an elegant way to select fields from a view, where a
I'm looking for most elegant way to ajaxify my forms (with jQuery). How do
I'm looking for an elegant way to suppress exceptions when calling a method. I
I'm looking for an elegant way to generate a sequence of the rolling average
I'm looking for an elegant way to use values in a Java enum to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.