-->
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: QueryException calling from public to internal class
PostPosted: Thu Jan 29, 2009 6:18 pm 
Newbie

Joined: Wed Feb 20, 2008 10:45 am
Posts: 10
Hi there

This might be a somewhat odd problem.

I have a public class which in it's constructor is calling an internal class, which in turn queries a mapped internal class.
Whenever I call the internal class from my test project everything works perfectly, but when I test the public class, my test fails with an NHibernate exception:

"QueryException: in expected: select [select r.Code from Resource r where r.Key in (:resourceKeys). "

The select is fine, the code is fine, the mapping seems fine (it runs in one case), but whenever it's called from another class the above exception occurs...

Can anyone help?

My solution was to do the select from SQL, since it's fine at the moment, but I have no idea why this particular exception occurs. The stacktrace doesn't reveal any valuable information either...

I think it has something to do with the internal access modifier, but I just can't make any sense out of it...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2009 5:38 am 
Newbie

Joined: Wed Feb 20, 2008 10:45 am
Posts: 10
Let me elaborate a bit:

I have three classes in the same assembly

Code:
namespace NS1
{
  public Foo
  {
    private string[] _resourceCodes;

    public Foo(ResObj ro)
    {
      RebindResourceCodes(ro.Keys);
    }

    private void RebindResourceCodes(string[] resourceKeys)
    {
      _resourceCodes = Bar.GetResourceCodes(resourceKeys);
    }
  }
}

namespace NS2
{
  internal Bar
  {
    public static string[] GetResourceCodes(params string[] keys)
    {
      // Access a new session and return values from Baz
      // Perform "select r.Code from Resource r where r.Key in (:resourceKeys)"
    }
  }

  internal Resource {
    public string Code { get; set; }
    public string Key { get; set; }
  }
}


In my very simple test-project I do the following (internals are visible to my test project BTW):

Code:
var codes = Bar.GetResourceCodes("a", "b", "c"); // Succeeds and returns correct results

var ro = new ResObj("a", "b", "c");
var foo = new Foo(ro); // Fails (exception outlined in the above post)



As far as I can see there should be no reason for the second test to fail. The exception is actually not really regarding the accessmodifiers, but changing the Resource class from internal to public solves the problem, but why???


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.