Code example for SessionFactory

Methods: openSession

0
 
		String nativeQuery = "select * from T_FOOS";
 
		hibernateQueryProvider.setSqlQuery(nativeQuery);
		hibernateQueryProvider.afterPropertiesSet();
		hibernateQueryProvider.setSession(sessionFactory.openSession());
 
		Query query = hibernateQueryProvider.createQuery();
 
		List<Foo> expectedFoos = new ArrayList<Foo>();
 
		expectedFoos.add(new Foo(1, "bar1", 1));
		expectedFoos.add(new Foo(2, "bar2", 2));
		expectedFoos.add(new Foo(3, "bar3", 3));
		expectedFoos.add(new Foo(4, "bar4", 4));
		expectedFoos.add(new Foo(5, "bar5", 5));
 
		@SuppressWarnings("unchecked") 
		List<Foo> actualFoos = query.list();