Package com.bean

Examples of com.bean.User


      Session session=factory.openSession()
       
      //creating transaction object 
      Transaction t=session.beginTransaction()
           
      User e1=new User()
      e1.setUsername("TESTHIBERNATE")
      e1.setPassword("efhwjwsfef");
      e1.setEmail("mmdd@dsjdj");
       
      session.persist(e1);//persisting the object 
       
      t.commit();//transaction is committed 
      session.close()
View Full Code Here


//            EntityManager em = emf.createEntityManager();
              
        int test = 0 ;
        switch (test) {
            case 0:
              User userToInsert = new User ();
              userToInsert.setUsername("PROVAJPA");
              userToInsert.setEmail("provaJPA_123");            
              userToInsert.setPassword("password123");  
              boolean userInserted = DBManager.executeInsert(userToInsert);
              System.out.println("Test.main - DEBUG - userInserted: " + userInserted);
              break;
            case 1:
//              executeSingleSelect(em);
View Full Code Here

    }
   
    //SINGLE SELCET FOR ID
    private static void executeSingleSelect (EntityManager em) {
        int userId = 26 ;
        User appo = (User) em.find(User.class, userId);     
        System.out.println("username: " + appo.getUsername() + " - email: " + appo.getEmail());       
    }
View Full Code Here

    }
   
    //SINGLE USER INSERT
    private static void executeInsert (EntityManager em) {
        em.getTransaction().begin();
        User appo = new User () ;
                
      
        appo.setUsername("Maurizio!!!");
        appo.setEmail("provaJPA_123");            
        appo.setPassword("password123");  
        em.persist(appo);           
        em.flush();
        em.getTransaction().commit();
        em.close();
      
        System.out.println("Inserted new User.... with username: " + appo.getUsername() + " - email: " + appo.getEmail());      
    }   
View Full Code Here

TOP

Related Classes of com.bean.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.