-->
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: Insert Operation shows Null values in MS SQL server database
PostPosted: Wed May 20, 2009 7:40 am 
Newbie

Joined: Wed May 20, 2009 7:32 am
Posts: 3
Hi Gurus,

Code:
public static void main(String[] args) {
      Session session = null;

      try{
         // This step will read hibernate.cfg.xml and prepare hibernate for use
         SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
          session =sessionFactory.openSession();
            //Create new instance of Contact and set values in it by reading them from form object
             System.out.println("Inserting Record");
            Contact contact = new Contact();
            //contact.setId(7);
            contact.setFirstName("Deepak");
            contact.setLastName("Kumar");
            contact.setEmail("deepak_38@yahoo.com");
            session.save(contact);
            System.out.println("Done");
      }catch(Exception e){
         System.out.println(e.getMessage());
      }finally{
         // Actual contact insertion will happen at this step
         session.flush();
         session.close();

         }
      
   }



I observed that with MySQL database, the insert operation perfectly works and i could verify the inserted values,
but with MS SQL even though the above code executes without any exceptions, i can see NULL tables values in database.

Does anybody haev any idea what might be going wrong ?

Thanks in advance,
Abhijit Salunkhe


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.