Code example for Session

Methods: closepersistbeginTransaction

0
	@Test
	public void testCreateTree() { 
		clearCounts(); 
 
		Session s = openSession();
		Transaction tx = s.beginTransaction();
		Node root = new Node("root"); 
		Node child = new Node("child"); 
		root.addChild(child); 
		s.persist(root);
		tx.commit();
		s.close();
 
		assertInsertCount(2); 
		assertUpdateCount(0); 
 
		s = openSession();
		tx = s.beginTransaction();
		System.out.println("getting");
		root = (Node) s.get(Node.class, "root");
Stop searching for code, let great code find you!  Add Codota to your java IDE