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

  • SEARCH
  • Home
  • 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 5942993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:19:53+00:00 2026-05-22T16:19:53+00:00

In book Java Persistence with Hibernate I came across a line that says: Hibernate

  • 0

In book “Java Persistence with Hibernate” I came across a line that says:

Hibernate produces all trivial CRUD SQL at startup. It caches the SQL statements
internally for future use, thus avoiding any runtime cost of SQL generation for the
most common operations. 

To see the startup log, it says:

Enable DEBUG logging for the org.hibernate.persister.entity package, and watch (or search) the
Hibernate startup log.

I have a trivial application with one entity Message that i’m persisting in the database.

I have enable show_sql=true in my config file. You could see my config file below:

<session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/ajax</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">XXXX</property>

    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <!-- Use the C3P0 connection pool provider -->
    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.max_size">20</property>
    <property name="hibernate.c3p0.timeout">300</property>
    <property name="hibernate.c3p0.max_statements">50</property>
    <property name="hibernate.c3p0.idle_test_period">3000</property>
    <!-- Show and print nice SQL on stdout -->
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <!-- List of XML mapping files -->
    <mapping resource="org/myapp/hibernate/first/Message.hbm.xml" />
</session-factory>

My Log4J.properties:

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE}%5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=DEBUG, stdout
# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=DEBUG
# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.type=DEBUG
log4j.logger.org.hibernate.persister.entity=DEBUG
log4j.logger.org.hibernate.SQL=DEBUG

With these settings, I could see the SQL getting printed on console when I save/update my entity.

but what I do not see is Start up log (that I mentioned at top). Hibernate did generate the SQL, but not at the start of application, it happened only when I started dealing with Entities.

What is wrong here?

  • 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-22T16:19:54+00:00Added an answer on May 22, 2026 at 4:19 pm

    It sounds like you’re expecting that at start up, you’ll see a series of SQL queries roll by. That’s not what happens.

    While Hibernate is computing the needed sql queries, it’s not actually running them, so you don’t see them via the “show_sql=true” logging directive.

    But if you have errors in named queries, for example, it will throw an exception at start up, which is one of the reasons I find using named queries very useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In core Java book it says The width of the rectangle that the getStringBounds
In my Java book, it says that an expression is a statement that can
In the book Java Persistence with Hibernate under the section titled Many Valued Associations
In the book Effective Java, Josh Bloch says that StringBuffer is largely obsolete and
I am reading a book about Java and it says that you can declare
While i was reading java book, i came across Every class extends class Object
I am new to Hibernate, reading this book Java persistence with Hibernate and I
In his book Java Design , Peter Coad says that one of the five
All, I'm going through the Friedman & Felleisen book A Little Java, A Few
Theres an exercise from a Java book I'm reading that has me confused: A

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.