Hi All,
Could anyone please explain why the two objects are not same?
Here is my code:
Code:
package com.cts.app;
import com.cts.to.Stock;
import com.cts.util.HibernateUtil;
import org.hibernate.Session;
public class TestApp3 {
public static void main(String args[]){
Session session1 = HibernateUtil.getSessionFactory().openSession();
Stock stock1 = (Stock)session1.load(Stock.class, 38);
//System.out.println("::::::Stock Name(1)::::::::"+stock1.getStockName());
session1.close();
session1 = HibernateUtil.getSessionFactory().openSession();
//Session session2 = HibernateUtil.getSessionFactory().openSession();
Stock stock2 = (Stock) session1.load(Stock.class, 38);
if(stock1 == stock2){
System.out.println("equal!!!");
}else{
System.out.println("not equal!!!");
}
}
}
Output:
not equal!!!