-->
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.  [ 4 posts ] 
Author Message
 Post subject: Looking for application design suggestions?
PostPosted: Wed May 19, 2004 7:02 am 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
Hello all,

How would you design an application that requires a user to build/modify an object graph over a 6-12 page flow in which the changes are not persisted to the database until after the flow is completed?

Using a petstore as an example: Say I put two fish in my cart. Because their id's are not generated until they are inserted into the database, how do you distinguish between them before they get persisted? I am interested to see how other hibernate users have designed a system around this problem.

Here is another problem. The user goes through this entire flow to remove a fish. At the end of the flow, my object graph is reflects that the fish has been removed. How do I then synchronize my object graph with what is currently in the database? (How do I keep track what was deleted in this situation?).

One solution to the above problem is to create a WIP (work in progress) schema which duplicates the "production" data schema. Data would be persisted as it is created and not rolled over to the "production" schema until the page flow is complete. Is there an easy way to pull this off in Hibernate? Do you really need to subclass all of your domain objects (to mark them as WIP) and duplicate the mapping files changing the default schema? There has got to be a better way.

Any suggestions?

Regards,

Joshua


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 9:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
From within the same session factory, yes you would need to duplicate the class hierarchies and mappings. However, the option does exist to simply use a seperate session facctory dedicated to your WIP work. This approach has a few benefits like the ability to physically seperate your "real" and "wip" schemas (like "real" runs on an Oracle HA cluster and "wip" runs on a local MySQL db).

If this interaction with the user is limited to a user session (i.e. an HttpSession) then you could look at caching their various selections and entries within the user session and then simply persist the whole shebang when they are completely done.


Top
 Profile  
 
 Post subject: Thanks for the reply!
PostPosted: Wed May 19, 2004 9:11 am 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
Steve,

I appreciate the reply.

I was originally intending to cache the object model in HttpSession.

Becasue a long page flow is involed, removing an object from the object model occurs at a different time than removing it from the database. (For example, the fish mentioned above may be removed from the model on page 2 of the flow, but not persisted until page 6) As a result, I am unsure how best to syncronize the object model with the relational model though.

Additions and modifications don't seem to be a problem. Deletions are. Do I need to build a custom mechanism to determine what objects have been deleted/removed from my model so I can take the appropriate action later in my page flow?

Joshua


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 9:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Really, deletions are the same as the additions and modifications in this scenario. A fish might get added to the domain model on page 2 but not persisted until page 6 (I don't know your page flow, but you get the jist).

The simpliest approach to this is what Hibernate terms "Detached Object Support". Your concerns about this approach are handled through Hibernate's cascade machinery. Do a search on the Hibernate site for "detached objects" for more information.

The other approach would be diconnected sessions. Hibernate lets you work with a session, disconnect it, reconnect it, and do more work with it. Keep in mind here that Hibernate does not synchronize the database state with the in-memory model state until the session is flushed. I have not played with this approach much, but i would think you would also need to come up with a scheme to utilize serializable transactions and come up with a scheme to suspend/resume the transactions at appropriate times.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.