-->
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.  [ 6 posts ] 
Author Message
 Post subject: SetFetchMode broken in 0.8.2
PostPosted: Fri May 13, 2005 7:55 pm 
Newbie

Joined: Fri May 13, 2005 7:46 pm
Posts: 17
I posted this on the other forum, and was asked to put it in JIRA, which I just tried to do, but it seems to be down right now. So I hope nobody minds if I post it here since I verified it with a quick test project. I'll try to get it to JIRA when it comes back up.

Here's the two classes involved in the test:



Code:
using System;
using System.Collections;

namespace SetFetchModeIssue
{
   public class Parent {
      Guid _id;
      string _name;
      IList _children;

      public Guid Id {
         get { return _id; }
         set { _id = value; }
      }

      public string Name {
         get { return _name; }
         set { _name = value; }
      }

      public IList Children {
         get { return _children; }
         set { _children = value; }
      }
   }
}

using System;

namespace SetFetchModeIssue
{
   public class Child {
      Guid _id;
      string _name;
      Parent _parent;

      public Guid Id {
         get { return _id; }
         set { _id = value; }
      }

      public string Name {
         get { return _name; }
         set { _name = value; }
      }

      public Parent Parent {
         get { return _parent; }
         set { _parent = value; }
      }
   }
}


And the mapping files for them:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="SetFetchModeIssue.Child, SetFetchModeIssue" table="Child">
      <id name="Id" type="Guid">
         <generator class="guid" />
      </id>
      <property name="Name" column="[Name]" type="String" length="50"/>
      <many-to-one name="Parent" not-null="true" />
   </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="SetFetchModeIssue.Parent, SetFetchModeIssue" table="Parent">
      <id name="Id" type="Guid">
         <generator class="guid" />
      </id>
      <property name="Name" column="[Name]" type="String" length="50"/>
      <bag name="Children" inverse="true" lazy="true">
         <key column="Parent" />
         <one-to-many class="SetFetchModeIssue.Child, SetFetchModeIssue" />
      </bag>
   </class>
</hibernate-mapping>



And here's the actual test:

Code:
using System;
using System.Collections;

using NHibernate;
using NHibernate.Cfg;

using NUnit.Framework;

namespace SetFetchModeIssue
{
   [TestFixture]
   public class SetFetchModeTestFixture
   {
      ISessionFactory sessions;

      [TestFixtureSetUp]
      public void RunBeforeAllTests() {
         Configuration cfg = new Configuration();
         cfg.AddAssembly("SetFetchModeIssue");
         this.sessions = cfg.BuildSessionFactory();
      }

      // This test works properly.
      [Test]
      public void GetParent() {
         using(ISession session = sessions.OpenSession()) {
            IList results = session.CreateCriteria(typeof(Parent)).List();

            Assert.AreEqual(1, results.Count);

            Parent parent = results[0] as Parent;

            Assert.IsNotNull(parent);

            Assert.AreEqual(4, parent.Children.Count);
         }
      }

      // This test works properly in 0.7. But fails in 0.8 (0.8.2 tested).
      // Instead of prefetching, the .SetFetchMode() call seems to basically
      // replace the ICriteria's "PersistentClass", Parent in this case,
      // with the Type of the relation, Child in this case.
      [Test]
      public void Prefetch() {
         using(ISession session = sessions.OpenSession()) {
            IList results = session.CreateCriteria(typeof(Parent))
               .SetFetchMode("Children", FetchMode.Eager).List();

            Assert.AreEqual(1, results.Count);

            Parent parent = results[0] as Parent;

            Assert.IsNotNull(parent);

            Assert.AreEqual(4, parent.Children.Count);
         }
      }
   }
}


Like the test comments say, I tried it with NHibernate .7 and it worked fine, but in .8 it's broken.

This is kinda a big deal for my current project, and time is very short, so I was thinking of reverting back to .7 until this is resolved. (Even though the release notes say .8 is a breaking change, I guess I'm not using Expressions in that manner since it was a drop-in replacement for me to goto .8).

EDIT: I'm sorry, I forgot to mention, this is with the MsSql2000Dialect. I'm not sure if that might make a difference.

EDIT2: JIRA seems to be back up, so I created issue NH-273 to cover this.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 14, 2005 5:15 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
We'll look into it, thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 7:17 pm 
I noticed 0.8.4 is out, and that was/is the version this issue was scheduled for. Does that mean this is resolved?

The second to the last item in the change log I thought might have something to do with it.


Top
  
 
 Post subject:
PostPosted: Thu May 26, 2005 12:36 am 
Newbie

Joined: Fri May 13, 2005 7:46 pm
Posts: 17
Nope :( Ran the test, still no worky. Maybe I'll try to pitch in...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 3:09 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
We wanted to get 0.8.4 out with the Firebird/Oracle/OleDb bug fix, other fixes (including this) will be delayed. Nobody has time currently, but some of us (me too) expect to have more time in the following weeks. I haven't put out the announcement for 0.8.4 yet because I didn't finish releasing.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 3:27 pm 
Newbie

Joined: Fri May 13, 2005 7:46 pm
Posts: 17
After a little digging I actually think I got the problem description wrong. I added a comment to the issue with more explanation.


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