I think nHibernate just "knows" to populate the first ? with Id (because Id is the first declared property of the class you are using to populate it?).
On Apr 2, 2:18 pm, jpcleve <[email protected]> wrote: > I've been following your thread on the other forum hoping for a > solution. > I have my example configured just as yours and it's almost working. My > problem is that I don't know how to define parameters for the prepared > sql statement. For example: > > <sql-query name="customLoader"> > <load-collection alias="dev" role="Page"/> > <![CDATA[SELECT * FROM PAGES WHERE Pages.fkbookId= :id]]> > </sql-query> > > how is ":id" being set? where is that parameter defined? > > Any ideas? > > On Apr 2, 12:32 pm, -_- <[email protected]> wrote: > > > Anyone have any sample code for populating a bag with a custom SQL > > SELECT statement? I need to be able to run a query using the object's > > id and it should return a list of another type of object. > > > The mapping code below demonstrates sorta what I need to do but this > > doesn't work. > > > Mapping Code: > > > <class name="Book" table="Devices"> > > <id name="Id" type="Int32" column="Id" access="property"> > > <generator class="identity"> > > <param name="table">Books</param> > > <param name="column">Id</param> > > </generator> > > </id> > > <bag name="PagesInBook" inverse="true"> > > <key></key> > > <one-to-many class="Pages"/> > > <loader query-ref="customLoader"/> > > </bag> > > </class> > > <class name="Page" table="Pages"> > > <id name="Id" type="Int32" column="Id" access="property"> > > <generator class="identity"> > > <param name="table">Pages</param> > > <param name="column">Id</param> > > </generator> > > <property name ="BookId" column="fkBookId"/> > > </id> > > </class> > > <sql-query name="customLoader"> > > <load-collection alias="dev" role="Page"/> > > <![CDATA[SELECT * FROM PAGES WHERE Pages.fkbookId= :id]]> > > </sql-query> > > > FOR MORE INFO you can look my forum post > > here:http://forum.hibernate.org/viewtopic.php?t=995589 > > > Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
