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.  [ 1 post ] 
Author Message
 Post subject: How to implement preview
PostPosted: Thu Dec 22, 2011 6:25 am 
Newbie

Joined: Thu Dec 22, 2011 6:09 am
Posts: 1
Hi. We have a quite common requirement of previewing changes on an object before storing the results in the DB. This is for a CMS.

The object is send from the frontend incomplete, i.e., in non-cascaded associations only the ID is sent, but in order to preview we need the full object. The preview involves marshalling the object into XML, which is then transformed to HTML using XSLT.

Session.refresh() only works with objects already in the session, so we thought about using a read only transaction, invoking Session.saveOrUpdate() and then Session.refresh(), so we have a "full" object to marshal to XML.

Unfortunately, Oracle JDBC driver doesn't support read only connections, so we are rolling back the transaction after that. This seems as it could work, but rolling back for previewing doesn't feel very elegant.

As this is a common use case, are there any other approaches that work for you?

Because we need the ability of previewing both new and already existing objects, we thought about resetting the ID of existing ones and storing a new object (replicating?) in the DB, but this has the problem of relationships with cascade update operations, which would be changed. I don't know if Session.replicate() would help with this, but I don't think so. Maybe Beanlib's HibernateBeanReplicator could help, but this seems as a more complex solution and it would pollute our DB.

Thanks in advance.


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

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.