Share on Google+Share on Google+

Hibernate Logging using Log4j

Ads
This section contains detail description of how you can use Log4j for logging configuration.

Hibernate Logging using Log4j

This section contains detail description of how you can use Log4j for logging configuration.

During development or after release, sometimes some unexpected error occurred with the application. To trace the error, logging is very helpful. Log4j is the tool which helps in displaying logs or keeping it's track(for example in a log file). Using Log4j logging can be enable at run time without modifying the application code.

In the below application, we included log4j-1.2.14.jar  in the lib directory to implement logging using Log4j. Log4j is reliable, faster and extensible. It is easy to understand and easy to implement.

Log4j has three main components :

  • Loggers        Loggers is used to log messages.     

  • Appenders  Appenders is used to determine the output destination like console or a file.

  • Layouts       Layouts decides the format log messages should be logged.

For details about the above components please click here.

The project structure is given below :

CODE

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://192.168.10.13:3306/ankdb</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>

<mapping class="net.roseindia.Worker" />

</session-factory>
</hibernate-configuration>

HandlingWorker.java

package net.roseindia;

import java.util.List;
import java.util.Iterator; 

import org.hibernate.HibernateException; 
import org.hibernate.Session; 
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;


public class HandlingWorker {
private static SessionFactory factory;
private static ServiceRegistry serviceRegistry;

public static void main(String[] args) {
try{
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); 
factory = configuration.buildSessionFactory(serviceRegistry);
}catch (Throwable ex) { 
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex); 
}
HandlingWorker handle = new HandlingWorker();

/* Add few worker records in database */
Integer worker1 = handle.addWorker("Kumar", "Dhawan", 1000);
Integer worker2 = handle.addWorker("Sriprakash", "Marathe", 5000);
Integer worker3 = handle.addWorker("Rudra", "Shah", 10000);

/* List down all the workers */
handle.listWorkers();

/* Update worker's records */
handle.updateWorker(worker1, 5000);
handle.updateWorker(worker3, 15000);

/* Delete an worker from the database */
handle.deleteWorker(worker2);

/* List down new list of the workers */
handle.listWorkers();
}
/* Method to CREATE an worker in the database */
public Integer addWorker(String fname, String lname, int salary){
Session session = factory.openSession();
Transaction tx = null;
Integer workerID = null;
try{
tx = session.beginTransaction();
Worker worker = new Worker(fname, lname, salary);
workerID = (Integer) session.save(worker); 
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace(); 
}finally {
session.close(); 
}
return workerID;
}
/* Method to READ all the employees */
public void listWorkers( ){
Session session = factory.openSession();
Transaction tx = null;
try{
tx = session.beginTransaction();
List employees = session.createQuery("FROM Worker").list(); 
for (Iterator iterator = 
employees.iterator(); iterator.hasNext();){
Worker worker = (Worker) iterator.next(); 
System.out.print("First Name: " + worker.getFirstName()); 
System.out.print(" Last Name: " + worker.getLastName()); 
System.out.println(" Salary: " + worker.getSalary()); 
}
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace(); 
}finally {
session.close(); 
}
}
/* Method to UPDATE salary for an worker */
public void updateWorker(Integer WorkerID, int salary ){
Session session = factory.openSession();
Transaction tx = null;
try{
tx = session.beginTransaction();
Worker worker = 
(Worker)session.get(Worker.class, WorkerID); 
worker.setSalary( salary );
session.update(worker); 
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace(); 
}finally {
session.close(); 
}
}
/* Method to DELETE an worker from the records */
public void deleteWorker(Integer WorkerID){
Session session = factory.openSession();
Transaction tx = null;
try{
tx = session.beginTransaction();
Worker worker = 
(Worker)session.get(Worker.class, WorkerID); 
session.delete(worker); 
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace(); 
}finally {
session.close(); 
}
}
}

Worker.java

package net.roseindia;

import javax.persistence.*;

@Entity
@Table(name = "Worker")
public class Worker {
@Id
@GeneratedValue
@Column(name = "id")
private int id;

@Column(name = "first_name")
private String firstName;

@Column(name = "last_name")
private String lastName;

@Column(name = "salary")
private int salary;

public Worker() {
}

public Worker(String fname, String lname, int salary) {
this.firstName = fname;
this.lastName = lname;
this.salary = salary;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}


public String getFirstName() {
return firstName;
}

public void setFirstName(String first_name) {
this.firstName = first_name;
}

public String getLastName() {
return lastName;
}

public void setLastName(String last_name) {
this.lastName = last_name;
}

public int getSalary() {
return salary;
}

public void setSalary(int salary) {
this.salary = salary;
}
}

log4j.properties

# Save log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\PROJECTLOG.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

# 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=INFO, file, stdout

# Log everything. Good for troubleshooting
log4j.logger.org.hibernate=INFO

# Log all JDBC parameters
log4j.logger.org.hibernate.type=ALL

The above configuration will  print the logs on console and also save the logs on the file saved in C: drive (C:\\PROJECTLOG.log). To download this log file click here.

OUTPUT

13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration boolean -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration boolean -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Boolean -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration numeric_boolean -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration true_false -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration yes_no -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration byte -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration byte -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Byte -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration character -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration char -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Character -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration short -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration short -> [email protected]
13:13:22,828 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Short -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration integer -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration int -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Integer -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration long -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration long -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Long -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration float -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration float -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Float -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration double -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration double -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Double -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration big_decimal -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.math.BigDecimal -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration big_integer -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.math.BigInteger -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration string -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.String -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration url -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.net.URL -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration date -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.sql.Date -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration time -> [email protected]
13:13:22,843 DEBUG BasicTypeRegistry:143 - Adding type registration java.sql.Time -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration timestamp -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.sql.Timestamp -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.Date -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration dbtimestamp -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration calendar -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.Calendar -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.GregorianCalendar -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration calendar_date -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration locale -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.Locale -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration currency -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.Currency -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration timezone -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.TimeZone -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration class -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Class -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration uuid-binary -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration java.util.UUID -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration uuid-char -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration pg-uuid -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration binary -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration byte[] -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration [B -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration wrapper-binary -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration Byte[] -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration [Ljava.lang.Byte; -> [email protected]
13:13:22,859 DEBUG BasicTypeRegistry:143 - Adding type registration image -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration characters -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration char[] -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration [C -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration wrapper-characters -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration [Ljava.lang.Character; -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration Character[] -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration text -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration blob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration java.sql.Blob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration materialized_blob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration clob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration java.sql.Clob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration materialized_clob -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration serializable -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration object -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration java.lang.Object -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration imm_date -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration imm_time -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration imm_timestamp -> [email protected]
13:13:22,875 DEBUG BasicTypeRegistry:143 - Adding type registration imm_dbtimestamp -> [email protected]
13:13:22,890 DEBUG BasicTypeRegistry:143 - Adding type registration imm_calendar -> [email protected]
13:13:22,890 DEBUG BasicTypeRegistry:143 - Adding type registration imm_calendar_date -> [email protected]
13:13:22,890 DEBUG BasicTypeRegistry:143 - Adding type registration imm_binary -> [email protected]
13:13:22,890 DEBUG BasicTypeRegistry:143 - Adding type registration imm_serializable -> [email protected]
13:13:22,906 INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
13:13:22,906 INFO Version:41 - HHH000412: Hibernate Core {4.0.0.Final}
13:13:22,906 INFO Environment:239 - HHH000206: hibernate.properties not found
13:13:22,906 INFO Environment:342 - HHH000021: Bytecode provider name : javassist
13:13:22,921 INFO Configuration:1920 - HHH000043: Configuring from resource: /hibernate.cfg.xml
13:13:22,921 INFO Configuration:1939 - HHH000040: Configuration resource: /hibernate.cfg.xml
13:13:22,968 WARN DTDEntityResolver:74 - HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
13:13:22,984 INFO Configuration:2061 - HHH000041: Configured SessionFactory: null
13:13:23,109 INFO DriverManagerConnectionProviderImpl:90 - HHH000402: Using Hibernate built-in connection pool (not for production use!)
13:13:23,109 INFO DriverManagerConnectionProviderImpl:110 - HHH000115: Hibernate connection pool size: 10
13:13:23,109 INFO DriverManagerConnectionProviderImpl:113 - HHH000006: Autocommit mode: false
13:13:23,109 INFO DriverManagerConnectionProviderImpl:127 - HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://192.168.10.13:3306/ankdb]
13:13:23,109 INFO DriverManagerConnectionProviderImpl:132 - HHH000046: Connection properties: {user=root, password=****}
13:13:23,281 INFO Dialect:120 - HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
13:13:23,296 INFO LobCreatorBuilder:94 - HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
13:13:23,296 INFO TransactionFactoryInitiator:68 - HHH000399: Using default transaction strategy (direct JDBC transactions)
13:13:23,296 INFO ASTQueryTranslatorFactory:48 - HHH000397: Using ASTQueryTranslatorFactory
13:13:23,312 TRACE TypeFactory:72 - Scoping types to session factory [email protected]
Hibernate: insert into Worker (first_name, last_name, salary) values (?, ?, ?)
13:13:23,546 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - Kumar
13:13:23,546 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - Dhawan
13:13:23,546 TRACE BasicBinder:83 - binding parameter [3] as [INTEGER] - 1000
Hibernate: insert into Worker (first_name, last_name, salary) values (?, ?, ?)
13:13:23,687 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - Sriprakash
13:13:23,687 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - Marathe
13:13:23,687 TRACE BasicBinder:83 - binding parameter [3] as [INTEGER] - 5000
Hibernate: insert into Worker (first_name, last_name, salary) values (?, ?, ?)
13:13:23,734 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - Rudra
13:13:23,734 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - Shah
13:13:23,734 TRACE BasicBinder:83 - binding parameter [3] as [INTEGER] - 10000
Hibernate: select worker0_.id as id0_, worker0_.first_name as first2_0_, worker0_.last_name as last3_0_, worker0_.salary as salary0_ from Worker worker0_
13:13:23,843 TRACE BasicExtractor:72 - Found [43] as column [id0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Kumar] as column [first2_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Dhawan] as column [last3_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [1000] as column [salary0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [44] as column [id0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Sriprakash] as column [first2_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Marathe] as column [last3_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [5000] as column [salary0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [45] as column [id0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Rudra] as column [first2_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Shah] as column [last3_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [10000] as column [salary0_]
First Name: Kumar Last Name: Dhawan Salary: 1000
First Name: Sriprakash Last Name: Marathe Salary: 5000
First Name: Rudra Last Name: Shah Salary: 10000
Hibernate: select worker0_.id as id0_0_, worker0_.first_name as first2_0_0_, worker0_.last_name as last3_0_0_, worker0_.salary as salary0_0_ from Worker worker0_ where worker0_.id=?
13:13:23,843 TRACE BasicBinder:83 - binding parameter [1] as [INTEGER] - 43
13:13:23,843 TRACE BasicExtractor:72 - Found [Kumar] as column [first2_0_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [Dhawan] as column [last3_0_0_]
13:13:23,843 TRACE BasicExtractor:72 - Found [1000] as column [salary0_0_]
Hibernate: update Worker set first_name=?, last_name=?, salary=? where id=?
13:13:23,859 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - Kumar
13:13:23,859 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - Dhawan
13:13:23,859 TRACE BasicBinder:83 - binding parameter [3] as [INTEGER] - 5000
13:13:23,859 TRACE BasicBinder:83 - binding parameter [4] as [INTEGER] - 43
Hibernate: select worker0_.id as id0_0_, worker0_.first_name as first2_0_0_, worker0_.last_name as last3_0_0_, worker0_.salary as salary0_0_ from Worker worker0_ where worker0_.id=?
13:13:23,890 TRACE BasicBinder:83 - binding parameter [1] as [INTEGER] - 45
13:13:23,890 TRACE BasicExtractor:72 - Found [Rudra] as column [first2_0_0_]
13:13:23,890 TRACE BasicExtractor:72 - Found [Shah] as column [last3_0_0_]
13:13:23,890 TRACE BasicExtractor:72 - Found [10000] as column [salary0_0_]
Hibernate: update Worker set first_name=?, last_name=?, salary=? where id=?
13:13:23,890 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - Rudra
13:13:23,890 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - Shah
13:13:23,890 TRACE BasicBinder:83 - binding parameter [3] as [INTEGER] - 15000
13:13:23,890 TRACE BasicBinder:83 - binding parameter [4] as [INTEGER] - 45
Hibernate: select worker0_.id as id0_0_, worker0_.first_name as first2_0_0_, worker0_.last_name as last3_0_0_, worker0_.salary as salary0_0_ from Worker worker0_ where worker0_.id=?
13:13:23,937 TRACE BasicBinder:83 - binding parameter [1] as [INTEGER] - 44
13:13:23,937 TRACE BasicExtractor:72 - Found [Sriprakash] as column [first2_0_0_]
13:13:23,937 TRACE BasicExtractor:72 - Found [Marathe] as column [last3_0_0_]
13:13:23,937 TRACE BasicExtractor:72 - Found [5000] as column [salary0_0_]
Hibernate: delete from Worker where id=?
13:13:23,937 TRACE BasicBinder:83 - binding parameter [1] as [INTEGER] - 44
Hibernate: select worker0_.id as id0_, worker0_.first_name as first2_0_, worker0_.last_name as last3_0_, worker0_.salary as salary0_ from Worker worker0_
13:13:23,984 TRACE BasicExtractor:72 - Found [43] as column [id0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [Kumar] as column [first2_0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [Dhawan] as column [last3_0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [5000] as column [salary0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [45] as column [id0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [Rudra] as column [first2_0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [Shah] as column [last3_0_]
13:13:23,984 TRACE BasicExtractor:72 - Found [15000] as column [salary0_]
First Name: Kumar Last Name: Dhawan Salary: 5000
First Name: Rudra Last Name: Shah Salary: 15000

In the worker table, you will get the following :

Download Source Code

Advertisements

Posted on: March 2, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Hibernate Logging using Log4j  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0