-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Why these two objects are not same?
PostPosted: Sat Nov 30, 2013 10:37 am 
Newbie

Joined: Tue Jun 23, 2009 3:06 am
Posts: 2
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!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.