-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Design question: versioning (revisioning) in applications
PostPosted: Tue Sep 26, 2006 12:44 am 
Newbie

Joined: Sat Jun 17, 2006 3:10 pm
Posts: 7
Location: Canada
I have an application that will be sending some complex data models to governement agencies via EDI. One requirement of the system is that once a message is accepted, we must maintain an accurate history for up to 7 years.

We've basically got a normalized domain model working with hibernate, but we want to implement "versioning" on many domain objects. For example, if we have a driver that is linked to a shipment and his home address changes (or any other member that gets transmitted to the government changes) we have to maintain accurate history of his old address (or name, drivers license, etc).

Another example is if you had a Invoice and it contained a list of Items. Even if the price member on an Item changes, all old invoices should maintain a history of the old price. Again, the same goes for most other members that would be present.

Does anyone have a strategy or design pattern for this type of system. The current solution we're looking at is having something like this as our base class:

public abstract class VersionedDomainObject implements VersionedObject {
private long id;
private boolean isActive();

public abstract VersionedObject getUpdatedVersion();
public abstract VersionedObject createNewVersion();

... getters and setters ...
}

Basically every new object would maintain a new version if one exists. This works great for simple cases, but doesn't work well for complicated cases with a bunch of many-to-one relationships. For example if I had an object like:

public class Foo extends VersionedDomainObject {
private String name;
private List<Bar> bars;
private Set<Whatever> whatevers;
....
}

When I want to make an updated version, I have a bunch of Bar and Whatever objects that are part of a many-to-one relationship with Foo, so I'd have to either create copies of all of them as well, or have a strategy link the objects as many-to-many relationships.

Anyway, does anyone have some experience solving this type of problem. I'm sure there is a nice elegant design, but I'm not seeing it at the moment.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 12:17 am 
Newbie

Joined: Sat Jun 17, 2006 3:10 pm
Posts: 7
Location: Canada
Does anyone have experience with this or some advice?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 12:26 am 
Newbie

Joined: Thu Oct 09, 2003 4:06 pm
Posts: 16
There are some good tools out there which will automatically modify your DB schema to add versioning / auditing and automatically add the triggers to all of the tables you specify. I don't have the names in front of me, but which you'll want is dependent on your database anyway. Some of them come with reporting and visualization tools, some don't.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:21 am 
Newbie

Joined: Sat Jun 17, 2006 3:10 pm
Posts: 7
Location: Canada
jcarreira wrote:
There are some good tools out there which will automatically modify your DB schema to add versioning / auditing and automatically add the triggers to all of the tables you specify. I don't have the names in front of me, but which you'll want is dependent on your database anyway. Some of them come with reporting and visualization tools, some don't.


Thanks... My database is PostgreSQL 8.1. I'm really looking for more of a design pattern that will work for me. I'm more concerned with making the domain model work well and persisting the "correct" implementation shouldn't be too big of a deal. I don't really want to use triggers for the type of "versioning" I'm talking about, but I'm interested in hearing anyones approach.

Thanks for the help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:27 am 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
If you haven't already, it's well worth having a look at this post in the NHbernate forum. It's the only way I can see to do this kind of versioning (as opposed to history tables) with hibernate.

http://forum.hibernate.org/viewtopic.php?t=955576


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.