These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: null id in entry (don't flush the Session after an exception
PostPosted: Tue Mar 06, 2007 12:10 pm 
Newbie

Joined: Tue Mar 06, 2007 10:47 am
Posts: 1
Hi

1.0.4.0

Session.FlushMode = FlushMode.Comit;


public static int saveUser(Usuario u)
{
OleDbException odbex;
int result = 1;
try
{
session.Reconnect();
transaction = session.BeginTransaction();
session.Save(u);
transaction.Commit();
result = 0;
}
catch(Exception ex)
{
transaction.Rollback();
if ((ex.InnerException != null) && (ex.InnerException is OleDbException))
{
odbex = (OleDbException)ex.InnerException;
result = odbex.ErrorCode;
}
else
{
result = 1;
}
}
finally
{
session.Disconnect();
}
return result;
}



Microsoft access 2003


I have 1 table named users. This table has a column named username that has a unique constraint.

if the application user try to insert in db 1 user with the same username it get's an exception, and inform to the application user via the result.


since this exception ocurrs if I try to do any operation with the database (session.createCriteria(typeof(User))) i alwais get this exception

"null id in entry (don't flush the Session after an exception"

May anyone help me??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.