-->
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.  [ 4 posts ] 
Author Message
 Post subject: no inserts as long as Identity_insert iss et to Off
PostPosted: Tue Jan 22, 2008 11:46 am 
Beginner
Beginner

Joined: Tue Jan 22, 2008 11:33 am
Posts: 46
Hi,

I have a database with an column „OrganizationalUnitId“ (primary key), which is set to Identity column in the database and is therefore auto assigned. What do I have to do in order to insert another row to the table?
The hbm.xml-file is:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="x.y.z.Person, x.y" table="OrganizationalUnit">
<id name="ObjectId" column="OrganizationalUnitId" type="Int32">
<generator class="assigned" />
</id>
<property name="TypeId" column="OrganizationalUnitTypeID" type="Int32"/>
<property name="StatusId" column="OrganizationalUnitStatusID" type="Int32"/>
</class>
</hibernate-mapping>


It complains that no explicit value can be inserted in the coulumn as long as Identity_insert iss et to Off.

How do I have to configure the file and how do I have to write tth code to add a row to Table with Identity Column?
How can I set Identity_insert either in the code or in hbm.xml file to ON? Or even better how can insert data without inserting the Identity Column?

Thanks in advance

antoschka


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 22, 2008 8:46 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
Use <generator class="identity"/> to tell NHibernate that the DB will assign id values.

_________________
Mike Abraham


Top
 Profile  
 
 Post subject: That's it
PostPosted: Wed Jan 23, 2008 4:29 am 
Beginner
Beginner

Joined: Tue Jan 22, 2008 11:33 am
Posts: 46
Hi,

thanks. It works great. I read in the documentation about native and that it will checkwhat database can actually support.
What's the difference between identity and native? Is there any Performance problem with native?

Thanks

antoschka


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 10:24 am 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
I believe that for a MS SQL Server database, identity and native are equivalent, and there is no performance difference between them.

_________________
Mike Abraham


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.