Actually hollow objects should inflate themselves. So looks like in
your case they are not just hollow, but also detached from the context
(check "object.getObjectContext()" - is it null?). So to locate their
registered and attached versions you can use ObjectIdQuery, like in
your example, or even more straightforward, DataObjectUtils.objectForPK:
hollowObject = (HollowObjectType)
DataObjectUtils.objectForPK(context, hollowObject.getObjectId());
In both cases cache will be used, so the performance of this is
roughly proportional to the speed of a HashMap lookup (plus a bit of
overhead to create the query object). Shouldn't be too bad at all.
Andrus
On Apr 2, 2010, at 1:46 AM, Nishant Neeraj wrote:
Seems like this does the trick
if(hollowObject.getPersistenceState() == PersistenceState.HOLLOW){
ObjectIdQuery query = new
ObjectIdQuery(hollowObject.getObjectId());
List<HollowObjectType> resultSet =
getDataContext().performQuery(query);
}
So, perhaps I will end-up in adding a layer that between Wicket and
Cayenne
that (a) Checks if object is HOLLOW, (b) Inflate, if 'a' is true.
Now, what is the impact on performance due to this layer... I am a bit
skeptical because I hope this should be using CACHE and not actually
querying DB. See Here [1].
[1]
http://cayenne.apache.org/doc30/api/org/apache/cayenne/query/ObjectIdQuery.html
Thanks
Nishant
On Fri, Apr 2, 2010 at 12:57 AM, Nishant Neeraj <
[email protected]> wrote:
Thanks for the reply.
Yes, Wicket does serialize/de-serialize objects to/from session-
store...
so, do I need to explicitly inflate the objects or there is a way
to make
sure deserialization occurs properly?
Thanks
Nishant
On Fri, Apr 2, 2010 at 12:38 AM, Andrus Adamchik
<[email protected]<[email protected]>
wrote:
I haven't used Wicket, but is there (de)serialization of objects
involved
when rendering a form and then submitting it back? This might
result in
turning an object to a hollow state. The last observation may be
due to the
object deserialized outside of its context...
Andrus
On Apr 1, 2010, at 9:28 PM, Nishant Neeraj wrote:
Also, when I "touch" (call getXXX) on the object it return empty
string.
On Thu, Apr 1, 2010 at 11:29 PM, Nishant Neeraj
<[email protected]
wrote:
Hi,
I am using Cayenne with Wicket.
There are situations when I see object's persistence state HOLLOW.
Specially, when I have committed something on a page, say by form
submission, .... then clicked browser back button to come back
to the
same
page and try to resubmit the form.
The problem is, when resubmitting, instead of over-writing the
same
object.. it is trying to insert it in DB.. but since it has
unique key
that
conflicts which previous commit, MySQL throws an exception.
I wanted to know what are the situations when a data object is
assigned
HOLLOW?
Thanks
Nishant