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: Example for Criteria and join query.
PostPosted: Mon Oct 27, 2008 12:56 pm 
Beginner
Beginner

Joined: Fri Feb 29, 2008 9:36 am
Posts: 40
Hi,

I search a simple example to use CreateCriteria with tables JOIN.

Today, I use the following code in my program:

Code:
NHibernate.ISQLQuery qry =
    session.CreateSQLQuery("SELECT Patients.last_name, Patients.patient_id, Patients.birth_date, Tests.acquisition_date, Tests.signature_date, Tests.signature, Tests.id_test, Tests.test_type FROM Tests INNER JOIN Patients ON Tests.id_patient = Patients.id_patient WHERE Tests.Enabled = 1");

ViewedTests result = new ViewedTests();
foreach (object[] item in qry.List())
{
    result.Add(new ViewedTest()
    {
        LastName = (String)item[0],
        Patient_id = (String)item[1],
        Birth_date = (DateTime?)item[2],
        Acquisition_Date = (DateTime?)item[3],
        Signature_Date = (DateTime?)item[4],
        Signature = (String)item[5],
        Id = (Int32)item[6],
        CodeTest = (Int32)item[7]
    });
}
return result;


Is it possible to do the same thing with ICriteria, more easy to add several filters and order on my query.

Papy!


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.