/** * */ package test;
import java.util.List;
import org.hibernate.Session; import
org.hibernate.SessionFactory; import
org.springframework.beans.factory.xml.XmlBeanFactory; import
org.springframework.core.io.ClassPathResource;
/** * @author shenshan * @version 1.0 *
*/ public class Test {
/** * @param args */ public static void main(
String[ ] args ) { ClassPathResource res = new ClassPathResource(
"applicationContext.xml" ); XmlBeanFactory factory = new XmlBeanFactory(
res ); SessionFactory sf = ( SessionFactory ) factory .getBean(
"mySessionFactory" ); Session sess = sf.openSession( );
List rs = sess.createQuery( "FROM test.GameCity" ).list(
);
for ( int i = 0; i < rs.size( ); i++
) { System.out.println( rs.get( i ) ); }
sess.close( );
}
} |