Code example for Session

Methods: closedeletebeginTransactioncreateCriteriacreateQuerygetTransaction

0
		bag.add(map);
		s.getTransaction().commit();
		s.close();
 
		s = openSession();
		s.beginTransaction();
		list = s.createQuery("from TestMap tm where tm.address = 'bar'").list();
		map = (Map) list.get(0);
		assertTrue( "foobar".equals( map.get("name") ) );
		assertTrue( "bar".equals( map.get("address") ) );
		assertTrue( map==map.get("parent") );
		bag = (List) map.get("children");
		assertTrue( bag.size()==1 );
 
		size = s.createCriteria("TestMap")
			.add( Restrictions.eq("address", "bar") )
				.createCriteria("parent")
				.add( Restrictions.eq("name", "foobar") )
			.list()
			.size();
		assertTrue(size==1);
 
		s.delete(map);
		s.getTransaction().commit();
		s.close();
 
	} 
 
	@Test
	public void testMapOneToOne() throws Exception {
Stop searching for code, let great code find you!  Add Codota to your java IDE