Try to commit the transaction

On Fri, Nov 7, 2008 at 7:30 PM, Gabriel Schenker <[EMAIL PROTECTED]>wrote:

> some thing like this (I added the Console.WriteLine for debugging purposes)
>
>         [Test]
>         public void try_load_blog_with_posts()
>         {
>             Console.WriteLine(">>>>First load...");
>             using (var session = SessionFactory.OpenSession())
>             {
>                 var blog1 = session.Get<Blog>(blog.Id);
>                 Console.WriteLine(">>>>>>>>Iterating posts...");
>                 foreach (var post in blog1.Posts)
>                     Console.WriteLine("{0} - {1}", post.Id, post.Title);
>             }
>             Console.WriteLine(">>>>Second load...");
>             using(var session = SessionFactory.OpenSession())
>             {
>                 var blog2 = session.Get<Blog>(blog.Id);
>                 Console.WriteLine(">>>>>>>>Iterating posts...");
>                 foreach (var post in blog2.Posts)
>                     Console.WriteLine(post.Id);
>             }
>       }
>
> here is the implementation of Blog
>
>     public class Blog
>     {
>         public virtual int Id { get; set; }
>         public virtual string Author { get; set; }
>         public virtual string Name { get; set; }
>         public virtual ISet<Post> Posts { get; set; }
>
>         public Blog()
>         {
>             Posts = new HashedSet<Post>();
>         }
>     }
>
> and of Post
>
>     public class Post
>     {
>         public virtual int Id { get; private set; }
>         public virtual string Title { get; set; }
>         public virtual string Body { get; set; }
>
>     }
>
> On Fri, Nov 7, 2008 at 6:24 PM, Ayende Rahien <[EMAIL PROTECTED]> wrote:
>
>> What is the code that you are using?
>>
>>
>> On Fri, Nov 7, 2008 at 7:21 PM, Gabriel Schenker <[EMAIL PROTECTED]>wrote:
>>
>>>
>>> I try to cache an aggregate consisting of a root object and a
>>> collection of children in the second level cache. I manage to cache
>>> the root entity in the cache but the child collection does not seem to
>>> bee cached. In the mapping file(s) I explicitly add the <cache>
>>> element to the collection and the child element and the config file
>>> contains the necessary entries to enable 2nd level caching.
>>> What am I missing?
>>>
>>>  My config file (using sql server compact edition and the Hashtable
>>> Cache Provider [for testing purposes only])
>>>
>>> <?xml version="1.0" encoding="utf-8" ?>
>>> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
>>>  <session-factory>
>>>    <property
>>>
>>> name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
>>> property>
>>>    <property name="dialect">NHibernate.Dialect.MsSqlCeDialect</
>>> property>
>>>    <property
>>> name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</
>>> property>
>>>    <property name="connection.connection_string">Data
>>> Source=CachingSample.sdf</property>
>>>    <property name="use_outer_join" >true</property>
>>>
>>>    <property
>>> name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider</
>>> property>
>>>    <property name="cache.use_second_level_cache">true</property>
>>>
>>>    <property name="show_sql">true</property>
>>>  </session-factory>
>>> </hibernate-configuration>
>>>
>>> the mapping file for my aggregate (the usual sample Blog-->Posts)
>>>
>>> <?xml version="1.0" encoding="utf-8" ?>
>>> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>>>                   namespace="Caching"
>>>                   assembly="Caching">
>>>  <class name="Blog">
>>>    <cache usage="read-write"/>
>>>    <id name="Id">
>>>      <generator class="hilo"/>
>>>    </id>
>>>    <property name="Author"/>
>>>    <property name="Name"/>
>>>    <set name="Posts" cascade="all" lazy="true">
>>>      <cache usage="read-write"/>
>>>      <key column="BlogId"/>
>>>      <one-to-many class="Post"/>
>>>    </set>
>>>  </class>
>>>
>>>  <class name="Post">
>>>    <cache usage="read-write"/>
>>>    <id name="Id">
>>>      <generator class="hilo"/>
>>>    </id>
>>>    <property name="Title"/>
>>>    <property name="Body"/>
>>>  </class>
>>> </hibernate-mapping>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Dr. Gabriel Schenker
> Apprimus Informatik GmbH
> In der Gass 19
> CH-8627 GrĂ¼ningen
>
> http://www.apprimus.ch
> [EMAIL PROTECTED]
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to