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: I can't save the entity with "assigned" generator.
PostPosted: Mon Sep 25, 2006 2:24 am 
Newbie

Joined: Mon Sep 25, 2006 2:07 am
Posts: 5
I have set the id like this:
<id name="UserId"
column="UserId"
type="System.String">
<generator class="assigned"/>
</id>

Then when I save the entity:
session.openSession();
session.save(entity);

But unfortunately, nothing has happend. No record is inserted into the database.

So what do I miss?

Thank you very much


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 6:45 am 
Newbie

Joined: Thu Apr 27, 2006 6:03 am
Posts: 14
Using session.Save(obj) you only save the object to the NHibernate cache. To store your object into the database, you have to call session.Flush() after session.Save(obj).

You can also use transactions. Then it ist not necessary to call Flush() explicitly.

ITransaction tx = session.BeginTransaction();
session.Save(obj);
tx.Commit();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 11:21 pm 
Newbie

Joined: Mon Sep 25, 2006 2:07 am
Posts: 5
RobRoma wrote:
Using session.Save(obj) you only save the object to the NHibernate cache. To store your object into the database, you have to call session.Flush() after session.Save(obj).

You can also use transactions. Then it ist not necessary to call Flush() explicitly.

ITransaction tx = session.BeginTransaction();
session.Save(obj);
tx.Commit();


Yes, it works.
Thanks


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.