Code example for Session

Methods: closeloadmergebeginTransactiongetTransaction

0
		// while detached, add a new element 
		me.getChildren().add( new Child( "Cece" ) );
		me.getChildren().add( new Child( "Austin" ) );
 
		s = openSession();
		s.beginTransaction();
		// load 'me' to associate it with the new session as a proxy (this may have occurred as 'prior work' 
		// to the reattachment below)... 
		Object meProxy = s.load( Parent.class, me.getName() );
		assertFalse( Hibernate.isInitialized( meProxy ) );
		// now, do the reattchment... 
		s.merge( me );
		s.getTransaction().commit();
		s.close();
 
		s = openSession();
		s.beginTransaction();
		s.createQuery( "delete from Child" ).executeUpdate();
		s.createQuery( "delete from Parent" ).executeUpdate();
		s.getTransaction().commit();
Experience pair programming with AI  Get Codota for Java