-->
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.  [ 1 post ] 
Author Message
 Post subject: Bulk insert using native query
PostPosted: Mon Dec 28, 2009 10:41 pm 
Newbie

Joined: Mon Dec 28, 2009 10:25 pm
Posts: 1
Hi all

I need to do a bulk insert of raw table data.
I need to use a Hibernate native query to insert the data.

I know how to do it using objects, but how can I do it using a native query ?

Code:
       
        Session session = sessionFactory.openSession();
        Transaction transaction = session.beginTransaction();   
        for (int i =0;i<100;i++)
        {
            EmployeeInfo employeeInfo = new EmployeeInfo();
            employeeInfo.setSno(1);;
            employeeInfo.setName("Value : "+String.valueOf(i));   
            session.save(employeeInfo);
            if (i%50 == 0)
            {
                session.flush();
                session.clear();
            }
        }
        transaction.commit();


Michael


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

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.