Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
AnswerRe: Casting Pin
V.8-Feb-10 21:24
professionalV.8-Feb-10 21:24 
AnswerRe: Casting Pin
AspDotNetDev8-Feb-10 23:10
protectorAspDotNetDev8-Feb-10 23:10 
QuestionHow to get DB Backup & Restore in Client machine Pin
Sivaooty8-Feb-10 20:03
Sivaooty8-Feb-10 20:03 
AnswerRe: How to get DB Backup & Restore in Client machine Pin
Gaurav Dudeja India8-Feb-10 20:06
Gaurav Dudeja India8-Feb-10 20:06 
GeneralRe: How to get DB Backup & Restore in Client machine Pin
Sivaooty8-Feb-10 22:17
Sivaooty8-Feb-10 22:17 
Questionstring to Font [modified] Pin
jojoba20108-Feb-10 19:57
jojoba20108-Feb-10 19:57 
AnswerRe: string to Font Pin
SeMartens8-Feb-10 20:49
SeMartens8-Feb-10 20:49 
QuestionNHibernate problem with inserting data: error performing isolated work [modified] Pin
dift8-Feb-10 19:33
dift8-Feb-10 19:33 
Hi
I'm newbie in NHibernate. I've downloaded example from: https://www.hibernate.org/379.html[^]

I can retreive data from database via iquery but i have a problem when I try save data.
Here is code:

Supplier supplier = new Supplier();
supplier.Name = "Supplier5";


Manufacturer manufacturer = new Manufacturer("manufacturer5");

Product product = new Product();
product.Name = "product5";

product.Supplier = supplier;
supplier.ProductList.Add(product);
manufacturer.ProductSet.Add(product);
product.ManufacturerSet.Add(manufacturer);

ITransaction transaction = Session.BeginTransaction();

try
{
  /*IQuery query = Session.CreateQuery("from Supplier as s order by s.Name asc");
   IList<Supplier> lSuppliers = query.List<Supplier>();
   foreach (Supplier supplier in lSuppliers)
   {
        string name = supplier.Name;
   }*/  // here ok

   Session.Save(supplier);  //error

   transaction.Commit();
}
catch (NHibernate.HibernateException nexp)
{
}


I've got an error:
error performing isolated work
InnerException: {"Object reference not set to an instance of an object."}

Here is mapping file supplier.hbm.file:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" default-access="nosetter.camelcase">
	<class name="NHibernateExampleApp.Supplier, NHibernateExampleApp" table="SUPPLIER" lazy="true" mutable="true">
		<id name="SupplierId" unsaved-value="0" column="ID_SUPPLIER" type="System.Int32">
			<generator class="hilo">
				<param name="table">hibernate_unique_key</param>
				<param name="column">next_hi</param>
				<param name="max_lo">10</param>
			</generator>
		</id>
		<bag name="ProductList" table="PRODUCT" cascade="all" fetch="join" inverse="true">
			<key column="FK_SUPPLIER" />
			<one-to-many class="NHibernateExampleApp.Product, NHibernateExampleApp" />
		</bag>
		<property name="Name" column="NAME" not-null="true" type="System.String" />
	</class>

	<query name="suppliers">from Supplier</query>
</hibernate-mapping>


StackTrace:

" at NHibernate.Transaction.AdoNetTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)\r\n at NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)\r\n at NHibernate.Engine.Transaction.Isolater.DoIsolatedWork(IIsolatedWork work, ISessionImplementor session)\r\n at NHibernate.Engine.TransactionHelper.DoWorkInNewTransaction(ISessionImplementor session)\r\n at NHibernate.Id.TableGenerator.Generate(ISessionImplementor session, Object obj)\r\n at NHibernate.Id.TableHiLoGenerator.Generate(ISessionImplementor session, Object obj)\r\n at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)\r\n at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)\r\n at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)\r\n at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)\r\n at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)\r\n at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)\r\n at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)\r\n at NHibernate.Impl.SessionImpl.Save(Object obj)\r\n at NHibernateExampleApp.Form1.NHTest() in D:\\rg\\proj_CSharp\\NHibernateExampleApp\\NHibernateExampleApp\\Form1.cs:line 136"

I can see that is a problem with hilo.
I have table: hibernate_unique_key
Column next_hi has value 0

Could someone help me?

Thanks
I
modified on Tuesday, February 9, 2010 1:44 AM

AnswerRe: NHibernate problem with inserting data: error performing isolated work Pin
dift8-Feb-10 19:50
dift8-Feb-10 19:50 
Questiongetcellbounds() of datagridviewcheckboxcell Pin
prithaa8-Feb-10 19:32
prithaa8-Feb-10 19:32 
Questionshell extention problem on 64 bit PC Pin
Nematjon Rahmanov8-Feb-10 17:38
Nematjon Rahmanov8-Feb-10 17:38 
AnswerDon't point back to a previous post Pin
Not Active8-Feb-10 17:47
mentorNot Active8-Feb-10 17:47 
GeneralRe: Don't point back to a previous post Pin
Nematjon Rahmanov8-Feb-10 19:11
Nematjon Rahmanov8-Feb-10 19:11 
AnswerRe: shell extention problem on 64 bit PC Pin
Dave Kreskowiak9-Feb-10 2:30
mveDave Kreskowiak9-Feb-10 2:30 
Questioncommand.exe double quoted arguments Pin
stmweb8-Feb-10 15:27
stmweb8-Feb-10 15:27 
AnswerRe: command.exe double quoted arguments Pin
Luc Pattyn8-Feb-10 16:14
sitebuilderLuc Pattyn8-Feb-10 16:14 
GeneralRe: command.exe double quoted arguments Pin
stmweb8-Feb-10 17:11
stmweb8-Feb-10 17:11 
GeneralRe: command.exe double quoted arguments Pin
Luc Pattyn8-Feb-10 23:47
sitebuilderLuc Pattyn8-Feb-10 23:47 
Questionhow would i filter results on my bindingnavigator when using a stored procedure call with linq? Pin
tonyonlinux8-Feb-10 14:54
tonyonlinux8-Feb-10 14:54 
AnswerRe: how would i filter results on my bindingnavigator when using a stored procedure call with linq? Pin
tonyonlinux9-Feb-10 15:37
tonyonlinux9-Feb-10 15:37 
GeneralRe: how would i filter results on my bindingnavigator when using a stored procedure call with linq? Pin
tonyonlinux9-Feb-10 16:53
tonyonlinux9-Feb-10 16:53 
QuestionCorrect technique for implementating a modal loop Pin
Jim Crafton8-Feb-10 9:00
Jim Crafton8-Feb-10 9:00 
AnswerRe: Correct technique for implementating a modal loop [modified] Pin
Luc Pattyn8-Feb-10 9:13
sitebuilderLuc Pattyn8-Feb-10 9:13 
Questiondatagridcheckbox in a datagrid Pin
prithaa8-Feb-10 7:06
prithaa8-Feb-10 7:06 
AnswerRe: datagridcheckbox in a datagrid Pin
OriginalGriff8-Feb-10 8:27
mveOriginalGriff8-Feb-10 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.