you are very fast with the replies... :-)) thanks... I missed the last
post before sending mine... So exactly... can I somehow produce a list
of FlatUser object out of the query that come with the scalars?

On Nov 3, 10:22 am, mitirino <[email protected]> wrote:
> Thank you very much. I know there is a way to create flat "report"
> type objects if you have an object with an appropriate constructor
> that takes the same arguments what come from a select.... but I can
> not find it in the documentation. (If you can help I'll appreciate it)
>
> I guess what you are saying makes sense for this type of queries...
> Thanks again.
>
> On Nov 3, 10:09 am, Fabio Maulo <[email protected]> wrote:
>
>
>
> > the query you are running with data reader is not loading the RealPosition
> > instance.
> > btw if you think that what you need is load 100000 rows or 200000 instances
> > (User+RealPosition) and the DataReader is doing the work you are looking for
> > well... use the DataReader way instead NH.
>
> > 2009/11/3 mitirino <[email protected]>
>
> > > Thank you. It does produce one query but runs 10 times slower than the
> > > very simmillar query with DataReader
>
> > > this is the query with DataReader
>
> > > command.CommandText = "SELECT u.name, u.year, p.name FROM User u JOIN
> > > Position p ON u.position_id=p.id;";
> > > using (SQLiteDataReader dataReader = command.ExecuteReader())
> > > {
> > >        while (dataReader.Read())
> > >        {
> > >                User user = new User(dataReader.GetString(0),
> > > dataReader.GetInt32
> > > (1), dataReader.GetString(2));
> > >                users.Add(user);
> > >        }
> > > }
>
> > > and with NH
>
> > >                IList<User> users =
> > >                        session.CreateQuery("select u from User u join
> > > fetch u.RealPosition").List<User>();
>
> > >                return users;
>
> > > On 100000 rows in User it runs within less than 1 sec with the
> > > DataReader.
>
> > > With the HQL you suggested NH is producing almost exact same SQL as
> > > the manual query above but runs in 12-13 sec.
>
> > > I realize it is not exactly equal test as the one with DataReader
> > > doesn't care for the Position objects but is there something I can do
> > > to get a comparable performance form NH?
>
> > > On Nov 2, 6:21 pm, Fabio Maulo <[email protected]> wrote:
> > > > select u from User u join fetch u.RealPosition
>
> > > > 2009/11/2 mitirino <[email protected]>
>
> > > > > Hi,
>
> > > > > I have many-to-one for User and Position and when I want to load the
> > > > > users it makes one select to get all the users and then one select per
> > > > > user to get the position for each one.
>
> > > > > Is there any way to avoid this and actually load everything with one
> > > > > select?
>
> > > > > Thank you
>
> > > > > ----
>
> > > > > IList<User> items = session.CreateQuery("from User").List<User>();
>
> > > > > ---
>
> > > > >  <class name="User" table="User" >
> > > > >    <id name="Id" column="id">
> > > > >      <generator class="native" />
> > > > >    </id>
> > > > >    <property name="Name" column="name" />
> > > > >    <property name="Year" column="year" />
> > > > >    <many-to-one name="RealPosition"
> > > > >                 class="Position"
> > > > >                 column="position_id" />
> > > > >  </class>
>
> > > > > ----
>
> > > > >  <class name="Position" table="Position" >
> > > > >    <id name="Id" column="id">
> > > > >      <generator class="native" />
> > > > >    </id>
> > > > >    <property name="Name" column="name" />
> > > > >  </class>
>
> > > > --
> > > > Fabio Maulo- Hide quoted text -
>
> > > > - Show quoted text -
>
> > --
> > Fabio Maulo- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to