Code example for Session

Methods: closegetbeginTransactiongetTransaction

0
		s.merge( user );
		s.getTransaction().commit();
		s.close();
 
		s = openSession();
		s.beginTransaction();
		user = ( User ) s.get( User.class, user.getId() );
		group = ( Group ) s.get( Group.class, group.getId() );
		membership = ( Membership ) s.get( membership.getClass(), membership.getId() );
		assertEquals( "user", user.getName() );
		assertEquals( "group", group.getName() );
		assertEquals( "membership", membership.getName() );
		assertEquals( 1, user.getMemberships().size() );
		assertEquals( 1, group.getMemberships().size() );
		assertSame( membership, user.getMemberships().iterator().next() );
		assertSame( membership, group.getMemberships().iterator().next() );
		assertSame( user, membership.getUser() );
		assertSame( group, membership.getGroup() );
		s.getTransaction().commit();
		s.close();
	} 
 
	@Test
	public void testRemoveAndAddEqualElement() { 
		deleteMembership( user, group, membership );
Contextual code suggestions in your IDE  Get Codota for Java