-->
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.  [ 2 posts ] 
Author Message
 Post subject: Batch insert in SQL Server with IDENTITY defined
PostPosted: Mon Jan 25, 2010 3:30 pm 
Newbie

Joined: Mon Jan 25, 2010 3:11 pm
Posts: 1
Hi,

I'm trying to make a batch insert working in SQL Server but I see no way of accomplishing it..

I have a table in SQL Server like

Code:
TABLE [dbo].[SomeTable]( [tableId] [int] IDENTITY(1,1) NOT NULL, ...
CONSTRAINT [PK_SomeTable] PRIMARY KEY CLUSTERED([tableId] ASC)...


and Hibernate mapping like

Code:
  <class name="SomeClass" table="SomeTable" schema="dbo" catalog="Something">
        <id name="tableId" type="int">
            <generator class="identity" />
        </id>

....

According to the batch insert tutorial Hibernate disables insert batching at the JDBC level transparently if you use an identity identifier generator.

So, I was thinking about other generator type, but I can't use an increment generator because I have a clustered key and it looks like I can't use an assigned one because I have IDENTITY(1,1) declared in SQL Server...

Could anybody give me some other options I can consider? Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Batch insert in SQL Server with IDENTITY defined
PostPosted: Wed Apr 13, 2011 7:46 am 
Newbie

Joined: Wed Apr 13, 2011 6:59 am
Posts: 2
Location: USA
To do bulk inserts, you have to create the SQL directly. However, Hibernate does allow you to get access to the connection from the Hibernate session using the doWork method. You can see example code of how to do it here.

http://i4hq.com/116-gbulk-inserts-with-hibernate-and-sqlserver


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.