Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:11:25+00:00 2026-05-28T07:11:25+00:00

In my hibernate properties I have <prop key=hibernate.jdbc.batch_size>30</prop> In my code I do something

  • 0

In my hibernate properties I have
<prop key=”hibernate.jdbc.batch_size”>30</prop>

In my code I do something similar to

final StatelessSession sSession = sessionFactory.openStatelessSession();
try {
    sSession.connection().setAutoCommit(false);
} catch (final SQLException se) {
    // log a message
}
final Transaction tx = sSession.beginTransaction();
try{
    for ( some loop ) {
        Customer customer = new Customer(.....);
        sSession.insert(customer);
        /* Do we need to flush a stateless session? It doesn't have methods for it
        if ( i % 30 == 0 ) { //30, same as the JDBC batch size
            //flush a batch of inserts and release memory:
            sSession.flush();
            sSession.clear();
        }
        */
    } 
    //sSession.flush();// Do we need to flush a stateless session? It doesn't have methods for it
    //sSession.clear();
} finally{
    tx.commit();
    sSession.close();
}

My Pojo has the following

@Id
//@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID", nullable = false, unique = true)
private Long id;

However, When I change the batch size it doesn’t seem to affect the overall run time. How can I verify that it is in fact working?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:11:26+00:00Added an answer on May 28, 2026 at 7:11 am

    comment out session.flush(); and see if anything is inserted after 20 loop interations

    Update: to the updated question

    commenting //@GeneratedValue(strategy = GenerationType.AUTO) should fall back to default which is AFAIK Identity

    try using

    @TableGenerator(name="TABLE_GEN", table="SEQUENCE_TABLE", pkColumnName="SEQ_NAME", valueColumnName="SEQ_COUNT", pkColumnValue="EMP_SEQ")
    @GeneratedValue(strategy=GenerationType.TABLE, generator="TABLE_GEN")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jar on the classpath which contains a hibernate.properties. This causes problems
I have a problem regarding the use of hibernate.properties and c3p0.properties. I am dependent
I have some auto-generated hibernate DAO code which was generated by Eclipse-hibernate reverse engineering
I am using Tomcat6/J2ee app with Hibernate jpa libraries. I have database connection properties
I have DAO code which contains some JDBC with Oracle-specific syntax, for example: select
Ok, I have this spring hibernate xml configuration. <bean id=sessionFactory class=org.springframework.orm.hibernate3.LocalSessionFactoryBean> <property name=dataSource ref=dataSource
Why can NHibernate create a proxy for classes with properties that have private setters
Can I configure hibernate properties to connect without using an instance name to sql
Hibernate 3.5-Final is finally here and it offers the much anticipated JPA2 support, amongst
I am trying to obtain Spring-defined Hibernate Configuration and SessionFactory objects in my non-Spring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.