protected void verifyHibernateConfig() throws Exception {
new HibernateTxFragment() {
protected void txFragment(Session session) throws Exception {
Map metadata = session.getSessionFactory().getAllClassMetadata();
for (Iterator i = metadata.values().iterator(); i.hasNext();) {
final AbstractEntityPersister persister = (AbstractEntityPersister) i.next();
final String className = persister.getName();
if (!ArrayUtils.contains(getDatabaseStructureVerificationExcludedClassNames(), className)) {
log.debug("Verifying: " + className);
new HibernateTxFragment(true) {
protected void txFragment(Session session) throws Exception {
try {
boolean usingOracle = isOracleDatabase();
Query query = session.createQuery("from " + className + " c " + (usingOracle ? " where rownum < 6" : ""));
if (!usingOracle) query.setMaxResults(5);
query.list();
}
catch (Exception e) {
log.error("Structure verification error for class " + className);
log.error("Error seems to affect table named " + persister.getTableName());
log.error("Please verify that all required database upgrades/creates are applied. Following stack trace may help you to determine the current error cause: ", e);
}
}}.execute();
}
}