Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

[NHibernate-development] named query problem

Erik Meusel

2008-01-11

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

I've got a problem (to solve ;) with an hbm mapping file looking like this:

...
<!-- Grid-Query -->
<resultset name="fastquerySet">
  <return alias="article" class="Article">
   <return-property name="Key" column="Artikelnummer" />
   <return-property name="CreatedAt" column="AngelegtAm" />
   <return-property name="ModifiedAt" column="GeaendertAm" />
   <return-property name="CreatedBy" column="AngelegtVon" />
   <return-property name="ModifiedBy" column="GeaendertVon" />
   ...
  </return>
  <return-join alias="producer" property="article.Producer">
   <return-property name="Key" column="Nummer" />
   <return-property name="Name" column="Name" />
  </return-join>
</resultset>

<sql-query name="fastquery" resultset-ref="fastquerySet">
  SELECT
  article.Artikelnummer,
  article.AngelegtAm,
  article.GeaendertAm,
  article.AngelegtVon,
  article.GeaendertVon,
  ...
  FROM ART article
  JOIN LIEFER producer
  ON article.Hersteller = producer.Nummer
</sql-query>
...

The tables mentioned are holding _far more than_ the columns I requested, which are not useful for me at this point, so I left them out of the mapping.

When I execute the named query via session.GetNamedQuery("fastquery").List<T>(); (with T being the (more complex) model type for table "ART"), I'll get the following System.OutOfRangeException: "Hersteller19_0_". "Hersteller" is one of the columns which are present in T but neither mapped in my query nor in the resultset, because I don't actually need it.

When I add "Hersteller" to both, it works. Do I really have to map every single column present in T? Am I able to go around this?


Thanks for your help!


Best regards,
Erik


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.