NHibernate: Session.Find throws Unique Index Exception -> but Finding should be Readonly!

  • Thread starter Thread starter blabla120
  • Start date Start date
B

blabla120

Hi folks,

I am net to NHibernate, and I hava a read baisc/general question.

In my database (PostgreSQL), I have an unique index laying on the field
transaktionsnummer which is located in the table payment.

I use the Find-Method of the Session class to query some objects:

ArrayList find = (ArrayList)Program.Session.Find("from payment where
transaktionsnummer = ? ", transaktionsnummer, NHibernateUtil.Int32);

What now happens amazes me : I get an Db-Exception "duplicate key
violates unique constraint uind_transaktionsnummer"

So my general question is: the Find-Method should be Read-Only,
shouldn't it? How can a querying function trhow a uniqe constraint
exception? It isn't supposed to write someting, or am I completely
wrong?

thanks for any Hints,

Bernd
 
I am net to NHibernate, and I hava a read baisc/general question.

In my database (PostgreSQL), I have an unique index laying on the field
transaktionsnummer which is located in the table payment.

I use the Find-Method of the Session class to query some objects:

ArrayList find = (ArrayList)Program.Session.Find("from payment where
transaktionsnummer = ? ", transaktionsnummer, NHibernateUtil.Int32);

What now happens amazes me : I get an Db-Exception "duplicate key
violates unique constraint uind_transaktionsnummer"

So my general question is: the Find-Method should be Read-Only,
shouldn't it? How can a querying function trhow a uniqe constraint
exception? It isn't supposed to write someting, or am I completely
wrong?

I suggest you turn on appropriate logging in NHibernate or Postgres to
see what SQL is being generated. That should make it clearer what's
going on.
 
Back
Top