What is difference between accessing the table single column and accessing the tabe with multiple column key »



Rep)
1) If the above table has to be accessed using hibernate we must provide a seperae class to hold the values of the columns(multiple) of the primary key.(We can call this class as primary key class)
–>As part of Empaddressid,it will contain the properties such as setId,getId as partid of empno,addrno.
2) In case of table [...]

Define create Session and SessionFactory »



Q) How to create Session and SessionFactory in Hibernate?
A)
Step 1> Put Hibernate properties in the classpath.
Step 2> Put .hbm.xml in class path ?
Code is Here to create session …

package com.dao;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
/**
*
* @author Satya Das
*/
public class HibernateUtil {
protected static final Logger
logger=Logger.getLogger(HibernateUtil.class);
public static String appHome = “No”;
private static SessionFactory [...]

Difference between getCurrentSession() and openSession() »



Q.Difference between getCurrentSession() and openSession() in Hibernate ?
A)
getCurrentSession() :
The “current session” refers to a Hibernate Session bound by Hibernate behind the scenes, to the transaction scope.
A Session is opened when getCurrentSession() is called for the first time and closed when the transaction ends.
It is also flushed automatically before the transaction commits. You can call [...]

Difference between session.update() and session.lock() »



Q)  Difference between session.update() and session.lock() in Hibernate ?

A) Both of these methods and saveOrUpdate() method are intended for reattaching a detached object.
The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object.
It is the best practice to [...]