InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Envers Joins Hibernate

Posted by Craig Wickesser on Dec 01, 2008

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
Data Access ,
Versioning ,
Java
Tags
Hibernate

Envers is an open-source project from JBoss which aims to provide easy versioning of persistent JPA classes. InfoQ provided information about the first GA release, 1.0.0, back in July of 2008. Since then Envers 1.1.0 was released which provided several new features.

The primary focus for the 1.1.0 release was the addition of support for persistent collections. Adam Warski, founder of Envers, described the new feature:

You can now version any relation, collections of “simple” types, maps, etc. All collection mappings defined by JPA are now supported, and most of what Hibernate additionally allows also.

The latest release also included some other improvements and bug fixes, as well as updates to the demos. With the continuing improvements to Envers, there is other news which was the source for this news item. On October 30, 2008 Envers officially became a module of Hibernate. The Envers website, documentation and forum will stay at there original home page for some time to come. The primary major changes were listed by Adam Warski on his blog:

  • The code is now in the hibernate-core repository (envers module). There will be no more commits to the old repository.
  • Issue tracking moved to Hibernate’s JIRA. All open issues from the old JIRA have been moved there.
  • Envers is now built using maven2, which replaces the old ant build

It's exciting times for Adam Warski and other contributors to Envers. The move to the Hibernate family should aid in the continued development of the Envers module and the further expansion into developers toolbelts when it comes to persisting Java objects.

How does envers handle circular references? by peter lin Posted
Re: How does envers handle circular references? by Adam Warski Posted
Re: How does envers handle circular references? by peter lin Posted
Re: How does envers handle circular references? by Adam Warski Posted
Re: How does envers handle circular references? by peter lin Posted
  1. Back to top

    How does envers handle circular references?

    by peter lin

    I'm curious, how does envers handles a situation where there's circular references? For example, say we have a model with bi-directional references like this.

    Person - has a collection of addresses
    Address - has a reference to the person

    How does envers know to skip a bidirectional reference and only traverse down the object graph and not back up.

  2. Back to top

    Re: How does envers handle circular references?

    by Adam Warski

    When saving changes, it's only needed to traverse 0 or 1 levels deep (depending on the settings).

    When loading changes, there is a "first-level cache", so you always attempt to load each entity at a revision once.

    Hope this answers your question :)

    Adam

  3. Back to top

    Re: How does envers handle circular references?

    by peter lin

    Thanks for responding. I looked for envers design docs late last night and couldn't find any. I finally decided to read the code, but couldn't quite make out the overall design.

    It sounds like the @versioned annotation gives users the ability to set the depth. I have another question, which I couldn't figure out from the website or forum.

    Say I have a large object graph and all the entities in that graph are versioned. Here is a hypothetical model.


    plan
    - Customer
    - list of addresses
    - PlanDetails
    - list of services
    - PlanRegion
    - list of region restrictions
    - PlanRestriction
    - PlanOptions
    - list of optios the customer has
    - PlanOption
    - ServiceHistory
    - list of service calls
    - ServiceCall


    If I add a new ServiceCall, does it revision the entire graph in the global revision, or does it maintain a parts list?

    thanks

    peter

  4. Back to top

    Re: How does envers handle circular references?

    by Adam Warski

    Hello,
    no, only a new revision for ServiceCall will be generated. If the relation with ServiceHistory is bidirectional, and a certain configuation option is set, a revision for ServiceHistory will also be generated.

    --
    Adam

  5. Back to top

    Re: How does envers handle circular references?

    by peter lin

    Sounds like Envers maintains a parts list. By that I mean does it keeps a list of all the records (id + version + timestamp) for each global version. I forgot to mention in the previous comment, the entire plan needs to be versioned including all the objects hanging off it. Is my interpretation correct or totally wrong.

    thanks

    peter

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.