List of usage examples for org.hibernate.tool.hbm2ddl SchemaValidator SchemaValidator
SchemaValidator
From source file:com.evolveum.midpoint.repo.sql.schemacheck.SchemaChecker.java
License:Apache License
private DataStructureCompliance determineDataStructureCompliance() { Metadata metadata = MetadataExtractorIntegrator.getMetadata(); try {//from w w w. j a v a2s . com new SchemaValidator().validate(metadata); LOGGER.debug("DB schema is OK."); return new DataStructureCompliance(DataStructureCompliance.State.COMPLIANT, null); } catch (org.hibernate.tool.schema.spi.SchemaManagementException e) { LOGGER.warn("Found a problem with DB schema: {}", e.getMessage()); LOGGER.debug("Exception", e); return new DataStructureCompliance( areSomeTablesPresent(metadata) ? DataStructureCompliance.State.NOT_COMPLIANT : DataStructureCompliance.State.NO_TABLES, e); } }
From source file:com.evolveum.midpoint.repo.sql.schemacheck.SchemaChecker.java
License:Apache License
private void validateAfterScript(String type) { try {/* www.ja va 2 s . com*/ new SchemaValidator().validate(MetadataExtractorIntegrator.getMetadata()); } catch (org.hibernate.tool.schema.spi.SchemaManagementException e) { logAndShowStopBanner("The following problem is present even after running the " + type + " script: " + e.getMessage()); LOGGER.error("Exception details", e); throw new SystemException( "DB schema is not OK even after running the " + type + " script: " + e.getMessage(), e); } }
From source file:org.unitedinternet.cosmo.db.DbInitializer.java
License:Apache License
/** * Schema validation// w ww . j av a 2s .c o m */ private void validateSchema() { try { StandardServiceRegistry registry = localSessionFactory.getConfiguration() .getStandardServiceRegistryBuilder().build(); MetadataSources sources = new MetadataSources(registry); sources.addPackage("org.unitedinternet.cosmo.model.hibernate"); Metadata metadata = sources.buildMetadata(registry); new SchemaValidator().validate(metadata); LOG.info("schema validation passed"); } catch (HibernateException e) { LOG.error("error validating schema", e); throw e; } }