|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-26 17:53:11
|
[ http://216.121.112.228/browse/NH-2677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo closed NH-2677.
---------------------------
Resolution: Not an Issue
You can't use that transformer when you are selecting two entities.
You need a custom transformer taking just the first one or you have to change the select clause.
For questions please use the nhusers group.
Thanks.
> CreateSQLQuery (used with AddEntity, AddJoin) resutls with cartesian product (not distincted entities)
> ------------------------------------------------------------------------------------------------------
>
> Key: NH-2677
> URL: http://216.121.112.228/browse/NH-2677
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.1.0
> Reporter: Mariusz Florek
>
> To get test case for this issue add another employment entity in [Test] public void SQLQueryInterface() method:
> Employment emp1 = new Employment(gavin, jboss, "AU1");
> s.Save(emp1);
> in a file:
> NHibernate-3.1.0.GA-src\src\NHibernate.Test\SqlTest\Query\NativeSQLQueriesFixture.cs
> (I used NHibernate 3.1.0.GA source code)
> Following code will result distincted Employment entities instead of expected Organization ones (I've tested it also in other structures - with similar results):
> s = OpenSession();
> t = s.BeginTransaction();
> l = s.CreateSQLQuery("select {org.*}, {emp.*} " +
> "from ORGANIZATION org " +
> " left outer join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER")
> .AddEntity("org", typeof(Organization))
> .AddJoin("emp", "org.employments")
> .SetResultTransformer(new DistinctRootEntityResultTransformer())
> .List();
> t.Commit();
> s.Close();
> Look at:
> public object TransformTuple(object[] tuple, string[] aliases)
> method in class:
> DistinctRootEntityResultTransformer
> implementation - when changed to: return tuple[0]; - works properly (this is hint - not solution).
> Cheers,
> Mariusz
> BTW - is it possible to get partial data from native sql transformed to entities f.e.:
> select a.Name, b.Category from Table1 a, Table2 b where a.table1_id = b.table1_id
> that will result as IList<Table1> (not a.*, b.*)? - link to example is welcome ;)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|