I'm not sure that's what I need. Restrictions.In has the pseudo signature

 

Restrictions.In (mappedProperty, collectionOfParams)

 

Whereas the HQL elements query allows you to do the 'inverse' which is:

 

Restrictions.In(param, mappedCollection)

 

I'm not seeing anything in Restrictions that supports the second case.

 

 

From: [email protected] [mailto:[EMAIL PROTECTED] On 
Behalf Of Tuna Toksöz
Sent: Monday, October 06, 2008 10:52 PM
To: [email protected]
Subject: [nhibernate-development] Re: FW: [nhusers] Re: Criteria querries and 
collections

 

crt.Add(Restrictions.In())

On Tue, Oct 7, 2008 at 8:10 AM, Jon Palmer <[EMAIL PROTECTED]> wrote:

I'm not sure I understand. Yes I could write the query using HQL like this:

 

Session.CreateQuery("from Person  p  where  '[EMAIL PROTECTED]' in elements 
(p.EmailAddresses)").List() 

The question is how do you perform the same query using the Criteria API?

 

Jon

From: [email protected] [mailto:[EMAIL PROTECTED] On 
Behalf Of Fabio Maulo
Sent: Monday, October 06, 2008 9:05 PM


To: [email protected]
Subject: [nhibernate-development] Re: FW: [nhusers] Re: Criteria querries and 
collections

 

in elements

2008/10/6 Tuna Toksöz <[EMAIL PROTECTED]>

No, it is not.

 

On Mon, Oct 6, 2008 at 7:27 PM, Tuna Toksöz <[EMAIL PROTECTED]> wrote:

Session.CreateQuery("from Person  p  join p.EmailAddresses e where e = '[EMAIL 
PROTECTED]'").List() 

this may be possible, i am not sure. Let me check

 

On Mon, Oct 6, 2008 at 7:18 PM, Jon Palmer <[EMAIL PROTECTED]> wrote:

Shame. I would have thought that collections and composite entities would 
actually be easier than mapped objects right?

 

From: [email protected] [mailto:[EMAIL PROTECTED] On 
Behalf Of Tuna Toksöz
Sent: Monday, October 06, 2008 9:15 AM
To: [email protected]
Subject: [nhibernate-development] Re: FW: [nhusers] Re: Criteria querries and 
collections

 

No it is not supported in criteria. i am thinking about what can be hard. I 
don't think there is a jira issue so feel free to create a issue.

On Mon, Oct 6, 2008 at 7:01 PM, Jon Palmer <[EMAIL PROTECTED]> wrote:

I figured the dev list might be a better place to ask this. Is there a Jira 
issue for this and if so what is hard about the fix?

 

Thanks

Jon

 

P.S. In HQL you can also do this:

 

Session.CreateQuery("from Person  p where p.EmailAddresses[0] = '[EMAIL 
PROTECTED]'").List()

 

Is there an equivalent using the Criteria API?

 

Jon Palmer
Senior Software Engineer, Contact Networks
35 Thomson Place T3 | Boston, MA 02210
O: 617.856.1836 | M: 415.269.1862

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Chavez
Sent: Monday, October 06, 2008 3:18 AM
To: [EMAIL PROTECTED]
Subject: [nhusers] Re: Criteria querries and collections

 

I think I tried doing this very same thing a few days ago, only with 
<.composite-element.> mappings.

 

>From what I found, the answer is no, I had to promote the element to a first 
>class POCO in order to do some querying with Criteria API.

 

I may be wrong, though, so wait for others to weight in.

 

-Brian

 

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Palmer
Sent: Monday, October 06, 2008 2:30 AM
To: [EMAIL PROTECTED]
Subject: [nhusers] Criteria querries and collections

 

Is the first item of 'Advanced Problems' on http://www.hibernate.org/117.html 
still true or do recent versions of NHibernate support querying collections 
though the Criteria API?

 

 

I have a simple situation like this:

 

Class Person

{

                IList EmailAddresses {get; set;}

}

 

 

The Email addresses are mapped as simple strings like this:

 

<class name="Person"/>

<list name="EmailAddresses" table="PersonEmailAddresses" lazy=" >

              <key column="PersonID"/>

              <index column="DisplayOrder"/>

              <element column="EmailAddress" type="string"/>

       </list>

</class>

 

In HQL I can do a query on the email Addresses like this:

 

Session.CreateQuery("from Person  p  join p.EmailAddresses e where e = '[EMAIL 
PROTECTED]'").List()

 

Is there an equivalent using the Criteira API? I've tried a number of things 
but they all break in some shape or form.

 

Thanks

Jon

 

Jon Palmer
Senior Software Engineer, Contact Networks
35 Thomson Place T3 | Boston, MA 02210
O: 617.856.1836 | M: 415.269.1862

 

Contact Networks, a Thomson Reuters company, is the global leader of B2B social 
networking for professionals.

 

 

 

 

 




-- 
Tuna Toksöz

Typos included to enhance the readers attention!




-- 
Tuna Toksöz

Typos included to enhance the readers attention!




-- 
Tuna Toksöz

Typos included to enhance the readers attention!




-- 
Fabio Maulo




-- 
Tuna Toksöz

Typos included to enhance the readers attention!

<<image001.gif>>

Reply via email to