See comments...
/*** Iterates through all mapped Hibernate classes and attempts to select* all for that table/class pair. If this test does not fail then this* indicates that the hibernate mappings at the very minimum match the* database schema.*/@Testpublic void allHibernateMappingsWork(){ Configuration configuration = new Configuration(); configuration.setProperty(Environment.SHOW_SQL, "true"); SessionFactory sessionFactory = configuration.configure().buildSessionFactory(); Session session = sessionFactory.openSession(); Map metaData = sessionFactory.getAllClassMetadata(); for (Iterator i = metaData.values().iterator(); i.hasNext();) { EntityPersister persister = (EntityPersister) i.next(); String className = persister.getClassMetadata().getEntityName(); String qry = "from " + className + " c"; List result = session.createQuery(qry).list(); assertTrue("No results for " + className, result.size() > 0); } session.close();}
Powered by: newtelligence dasBlog 2.1.8102.813
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Shawn Neal
E-mail