Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011 Vecna Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.vecna.dbDiff.hibernate;
Compares hibernate configuration schema to the schema of the live database the configuration points to.

public class HibernateSchemaValidator {
  private final Configuration m_configuration;

Create a new instance

configuration hibernate configuration
  public HibernateSchemaValidator(Configuration configuration) {
     = configuration;

Compare schemas

list of schema differences
com.vecna.dbDiff.model.relationalDb.RelationalValidationException if schemas can't be retrieved/built
java.sql.SQLException if live schema can't be retrieved
    String jdbcDriver = .getProperty("hibernate.connection.driver_class");
    String jdbcUrl = .getProperty("hibernate.connection.url");
    String jdbcUser = .getProperty("hibernate.connection.username");
    String jdbcPassword = .getProperty("hibernate.connection.password");
    CatalogSchema catalogSchema = DefaultCatalogSchemaResolverFactory.getCatalogSchemaResolver()
    RelationalDatabase hibernateSchema = new HibernateMappingsConverter(catalogSchema).convert();
    Connection conn;
    conn = DriverManager.getConnection(jdbcUrljdbcUserjdbcPassword);
    RelationalDatabase liveSchema;
    try {
      MetadataDao metadataDao = new GenericMetadataDaoImpl(conn);
      CatalogSchema cs = new CatalogSchema(null"public");
      liveSchema = rdbBean.createRelationalDatabase(cs);
    } finally {
    return new RdbDiffEngine().compareRelationalDatabase(hibernateSchemaliveSchema);
New to GrepCode? Check out our FAQ X