I'm trying to re-update an object after a transaction fails, but when I try to call Update() the second time, the new data is not used in the query.
Is this a bug, or is its just not possible to this?
Code:
using (ISession session = OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
Customer customer = (Customer)session.Load(typeof(Customer), 16, LockMode.UpgradeNoWait);
customer.Company = "verylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylongverylong";
try
{
session.Update(customer);
tx.Commit(); // throws exception, because Company is varchar(255)
}
catch
{
tx.Rollback();
customer.Company = "test";
using (ITransaction tx2 = session.BeginTransaction())
{
session.Update(customer);
tx2.Commit(); // The same query as before is executed, with the long value of "Company". Ofcourse, this throws the same exception as above.
}
}
}
}