-->
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: QBE with Associations
PostPosted: Sun Nov 12, 2006 9:37 pm 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
Hi.

I'm using NH 1.2 Alpha and would like to know why my QBE queries using associations does not work.

I'm using the following query:

Code:
public static IList<Cliente> List(int idRepresentante)
{
    Representante representante = RepresentanteDAL.Get(idRepresentante);
    Cliente cliente = new Cliente();
    cliente.Representante = representante;

    return BaseDAL.List<Cliente>(cliente, null);
}


My BaseDAL.List<T> is here:

Code:
public static IList<T> List<T>(object sample, string propName)
{
    ICriteria criteria = NHibernateHelper.Session.CreateCriteria(sample.GetType());
    Example example = Example.Create(sample);
    example.ExcludeZeroes();
    criteria.Add(example);

    if (propName != null)
    {
        order order = new Order(propName, false);
        criteria.AddOrder(order);               
    }

    return criteria.List<T>();
}


This query (using an object as example) returns all records. The "where" clause is "Where (1=1)".

I've made a test using EqExpression and it has worked fine. The test is:

Code:
public static IList<Cliente> List(int idRepresentante)
{
    Representante representante = RepresentanteDAL.Get(idRepresentante);
    ICriteria criteria = NHibernateHelper.Session.CreateCriteria(typeof(Cliente));
    criteria.Add(new EqExpression("Representante", representante));
    return criteria.List<Cliente>();
}


So, the first way is wrong? I can't use association when I use object by example?

Thanks :~)


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.