-->
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: unable to resolve org.hibernate.jdbc.Work
PostPosted: Tue Aug 02, 2016 8:06 am 
Newbie

Joined: Tue Aug 02, 2016 7:43 am
Posts: 2
Hello All,

I am new to hibernate and will want to do batch insert.
I came across this code below but my Netbeans IDE 8.1 is unable to resolve
Quote:
org.hibernate.jdbc.Work
and session.doWork .The Hibernate framework in the IDE is 4.3

Please assist .

import org.hibernate.jdbc.Work;

public void saveBatch ( List list) {
Transaction trns = null;
Session session = HibernateUtil.getSessionFactory().openSession();
trns = session.beginTransaction();

session.doWork(new Work() {
@Override
public void execute(Connection conn) throws SQLException {
PreparedStatement pstmt = null;
try{
String sqlInsert = "insert into sampletbl (name) values (?) ";
pstmt = conn.prepareStatement(sqlInsert );
int i=0;
for(String name : list){
pstmt .setString(1, name);
pstmt .addBatch();

//20 : JDBC batch size
if ( i % 20 == 0 ) {
pstmt .executeBatch();
}
i++;
}
pstmt .executeBatch();
}
finally{
pstmt .close();
}
}
});
trns.commit();
session.close();
}


Top
 Profile  
 
 Post subject: Re: unable to resolve org.hibernate.jdbc.Work
PostPosted: Tue Aug 02, 2016 8:15 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
That class is in hibernate-core. Check it out on GrepCode. You need to check how NetBeans is configured. I use IntellijIDEA, and it works like a charm.


Top
 Profile  
 
 Post subject: Re: unable to resolve org.hibernate.jdbc.Work
PostPosted: Tue Aug 02, 2016 9:08 am 
Newbie

Joined: Tue Aug 02, 2016 7:43 am
Posts: 2
Thank you mihalcea_vlad.
I removed the hibernate library ,added it again and clicked clean and build.
It is working now.


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.