Exception: SqlNode's text did not reference expected number of columns

1,511 views
Skip to first unread message

VD

unread,
Mar 17, 2010, 11:07:13 AM3/17/10
to nhusers
I faced with this exception in my big solution, but I localized the
problem to small project:
I have an A class which has composite key with specific type.
Then I try to make custom update which looks like:
ISession session = sessionFactory.OpenSession();
session.CreateQuery("update A a set a.Data = :data
where a.Id = :id").SetString("data", "some data").
SetParameter("id", new AId(1, 1)).
ExecuteUpdate();
ExecuteUpdate leads me to exception: "SqlNode's text did not reference
expected number of columns".

Mappings:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Main"
assembly="Main">

<class name="A" table="A">
<composite-id name="Id" class="AId">
<key-property name="Id" column="Id" />
<key-property name="SecondId" column="SecondId" />
</composite-id>
<property name="Data" />
</class>

</hibernate-mapping>
Classes are very simple, I hope it is not requred to reproduce the
problem...

John Davidson

unread,
Mar 17, 2010, 1:02:23 PM3/17/10
to nhu...@googlegroups.com
Composite keys seem to require extra special handling, beyond the logical expectation It is explained well here

http://devlicio.us/blogs/anne_epstein/archive/2009/11/20/nhibernate-and-composite-keys.aspx

Hope this helps

John Davidson


--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.


Valery Dubrava

unread,
Mar 18, 2010, 1:22:50 AM3/18/10
to nhu...@googlegroups.com
I have already read it. But I didn't understand, how it helps me?
I can not understand, why NHibernate can compare object using composite ID in Session.Update method, but it can't do it when I make update in HQL?
Reply all
Reply to author
Forward
0 new messages