
Wednesday, December 31, 2014
Explain about Hibernate Object Life Cycle?

In hibernate object life cycle, mainly consists of four states. They are Transient State, Persistent State, Detached State and Removed State.Hibernate Object Life Cycle1. New or Transient State:When ever an object of a POJO class is Created(instantiated) using the new operator then it will be in the Transient state; this object is not associated with any Hibernate Session.For example,Employee employee = new Employee("Ranga",...
Monday, December 29, 2014
Explain about System.out.println()
System.out.println() System is a final class available in java.lang package. It is a system related class and most of times make native calls.Structure of System class:public final class System { public final static InputStream in = null; public final static PrintStream out = null; public final static PrintStream err = null; private...
Compiling and Running Java program by using another Java program.
package com.ranga;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;/** Program: Compiling and Running Java program by using another Java program. java.lang.Runtime.exec()*/public class Main { public static void main(String[] args) { System.out.println("I am in Main class begin."); Process process = null; try { process = Runtime.getRuntime().exec("javac Test.java"); System.out.println("Test class successfully compiled."); } catch (IOException ex) { ...
Sunday, December 28, 2014
Different ways to get the Connection object using Hibernate
Getting the java.sql.Connection object using Session:---------------------------------------------------------------------------org.hibernate.Session is nothing but get the one physical connection from the database. By using Session we can get the Connection object several ways.1) session.connection() - this method is deprecated. it is not available on Hibernate4.2) session.doWork() - this method doesn't return Connection object, but inside what ever operation we want to do using connection object we can do. 3) session.doReturningWork() -...
How to Create Custom Dialect class in Hibernate?
Creating a Custom Dialect in Hibernate:In order to create any new Dialect class we need to extends org.hibernate.dialect.Dialect class. Dialect class is a abstract class.If you look at the Dialect class,public abstract class Dialect implements ConversionContext { protected Dialect() { // here we are registering the functions, ColumnType, HibernateTypes // for registering function's we can use registerFunction() method. // for registering columntype's we can use registerColumnType() method. // for registering...