Package

Source Code of HibernateTestAuto

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.metadata.ClassMetadata;


/*
* Created on 07-Dec-2004
*
*/

/**
* @author max
* TODO: auto generate this stuff
*/
public class HibernateTestAuto {
 
  public static void main(String[] args) {
    Configuration cfg = new Configuration();
   
    cfg.configure("/hibernate.cfg.xml");
   
    SessionFactory factory = cfg.buildSessionFactory();
   
    Session session = factory.openSession();
   
    Map allClassMetadata = factory.getAllClassMetadata();
   
    Iterator iterator = allClassMetadata.values().iterator();
   
    while (iterator.hasNext() ) {
      ClassMetadata element =  (ClassMetadata) iterator.next();
     
      List list = session.createQuery("from " + element.getMappedClass().getName() ).list();
      System.out.println(list);
    }
  }

}
TOP

Related Classes of HibernateTestAuto

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.