-->
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.  [ 2 posts ] 
Author Message
 Post subject: Readonly cache + Save works with certain order: Intended?
PostPosted: Fri May 11, 2007 5:28 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 10:32 am
Posts: 34
We do the following:

We have a class VAT mapped with <cache usage="read-only"/>.

In a setup program using NHibernate, we do (about) the following:

VAT v = new VAT();
v.Percentage = 19.0;
v.Name = "Full VAT";
session.Save(v);

This works.

In a test case, someone wrote:

VAT v = new VAT();
session.Save(v);
v.Percentage = 19.0;
v.Name = "Full VAT";
...flush+commit follows much later...

This leads to an InvalidOperationException "Can't write to a readonly object" from the class ReadonlyCache's Lock method.

The behavior stems from the fact that NHibernate (and, AFAIK, Hibernate) creates a new object in a somewhat roundabout way: It remembers the object exactly at the point of the Save(); and then does a compare when it flushes the new object. From these, it emits an INSERT and an UPDATE.

---> If this behavior is stable (you *can* create a new object with a *readonly-cache* if you take care that no changes are done after Save()) and will be supported for all future, we are happy and will use this idiom.

---> If not, how should a program work that wants to insert objects for a class marked with <cache usage="read-only"/>?

Regards
Harald M.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 11, 2007 6:10 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, you can consider this behavior stable.


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