Tutorial66.com
@Share Application Development Skill.



Tutorial is tutorial...66 is My Country Code Up to 10 Years EXP for Application Development Role in Thailand.
collapse

Tutorial Category



Topic: Hibernate Load Session Factory for Test in Stand alone  (Read 217 times)


My Development skill
Java JSP Servlet EJB
Spring Framework
Hibernate Framework
iReport Jasper Report
Apache CXF
PHP Codigniter
Oracle PLSQL
Unix Shell Script
Hibernate Load Session Factory for Test in Stand alone
« on: October 25, 2011, 06:33:31 AM »
In J2EE Env Container will load Session factory from config for you.
But if you need to test it in stand alone mode  you can load it like this example

Example for Load Hibernate Session Factory with Java Class
Code: [Select]
SessionFactory sessionFactory = new AnnotationConfiguration()
                    .addPackage("com.test")
                    .addAnnotatedClass(ExampleHibernate1.class)
                    .addAnnotatedClass(ExampleHibernate2.class)
                    .addAnnotatedClass(ExampleHibernate3.class)
                    .addAnnotatedClass(ExampleHibernate4.class)
                    .addResource("mytable.xml") //for hibernate mapping XML
                    .configure()
                    .buildSessionFactory();

You can use sessionFactory Object for work with hibernate Query




SimplePortal 2.3.3 © 2008-2010, SimplePortal