-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help with very basic Session.Save(object)
PostPosted: Sat Jul 23, 2005 2:47 pm 
Newbie

Joined: Sat Jul 23, 2005 2:36 pm
Posts: 1
Hi all
I just started with .net
Everything is so easy with java-hibernate.

I have everything setup in VS .net 2003 . I have a valid Hibernate Session.
When I try to save using Session.Save(object), no exception is thrown. When I execute transaction.commit, exception is thrown.

I have the same User object supplied in the samples with all properties defined.

Confirmed again, there is no data in the table. So its empty. This is the first insert. And error looks like a duplicate key.? Please help
Database: MS SQL Server 2000
.Net Framework: 1.1 on Windows XP Prof

Here is the exception:

{"could not synchronize database state with session" }
[NHibernate.ADOException]: {NHibernate.ADOException}
System.Object: {NHibernate.ADOException}
_className: null
_COMPlusExceptionCode: -532459699
_exceptionMethod: <undefined value>
_exceptionMethodString: null
_helpURL: null
_HResult: -2146232832
_innerException: {"Violation of PRIMARY KEY constraint 'PK__users__276EDEB3'. Cannot insert duplicate key in object 'users'.\r\nThe statement has been terminated." }
_message: "could not synchronize database state with session"
_remoteStackIndex: 0
_remoteStackTraceString: null
_source: null
_stackTrace: {System.Array}
_stackTraceString: null
_xcode: -532459699
_xptrs: 0
HelpLink: null
HResult: -2146232832
InnerException: {"Violation of PRIMARY KEY constraint 'PK__users__276EDEB3'. Cannot insert duplicate key in object 'users'.\r\nThe statement has been terminated." }
Message: "could not synchronize database state with session"
Source: "NHibernate"
StackTrace: " at NHibernate.Impl.SessionImpl.Execute()\r\n at NHibernate.Impl.SessionImpl.Flush()\r\n at NHibernate.Transaction.AdoTransaction.Commit()\r\n at nukaladotnet._default.Button1_Click(Object sender, EventArgs e) in c:\\inetpub\\wwwroot\\dotnettest\\default.aspx.cs:line 105"
TargetSite: {System.Reflection.RuntimeMethodInfo}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 23, 2005 5:28 pm 
Beginner
Beginner

Joined: Thu May 12, 2005 2:14 am
Posts: 33
Location: Sweden, Sk
Hi

Please post your hbm then it gets easier to find the errors.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 10:14 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Are you assigning the primary keys ?

Post your main() code also :)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


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

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.