Code example for Session

Methods: closepersistbeginTransactiongetTransaction

0
	} 
 
	@Test
	public void testMergeBidiPrimayKeyOneToOne() throws Exception {
		Session s = openSession();
        s.beginTransaction();
		Person p = new Person( "steve" );
		new PersonalDetails( "I have big feet", p );
		s.persist( p );
		s.getTransaction().commit();
		s.close();
 
		clearCounts(); 
 
		p.getDetails().setSomePersonalDetail( p.getDetails().getSomePersonalDetail() + " and big hands too" );
		s = openSession();
        s.beginTransaction();
		p = ( Person ) s.merge( p );
		s.getTransaction().commit();
		s.close();