-->
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: 1st Level Cache problem
PostPosted: Thu Dec 01, 2011 7:14 am 
Newbie

Joined: Tue Dec 22, 2009 8:38 am
Posts: 18
Hi,

I have a one-to-many relationship Article-Variables.

First I add some variables to in the articles variables collection, and save them :

public void SaveOrUpdate(T persistentObject, ISession session = null)
{
try
{
if (session == null)
{
session = this.OpenSession();
}

BeginTransaction();

session.SaveOrUpdate(persistentObject);

if (autoCommit)
CommitTransaction();

session.Refresh(persistentObject);
}
catch (Exception ex)
{
RollbackTransaction();
}
finally
{
if (autoCloseSession)
CloseSession();
}
}

The changes are successfully propagated to the database - I load the Article and I can see that the Variables collection contains elements.

Then I remove the elements in the Variables collection, and save the changes with the same method. The changed are propagates in the database (i can see the delete queries running, and also i can check that the corresponding records are deleted from the database), But when I load again the Article, it still features the corresponding Variables collection with items in it.

What am I doing wrong ? By calling session.Refresh(persistentObject); I am supposed to refresh the object in the session. Loading the Article reaches everytime the database, as I can see it in the debugger - still the returned records are the outdated ones.

Can you help me ? Thank you.


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.