Package org.hibernate.tool.hbmlint

Examples of org.hibernate.tool.hbmlint.Issue


  }
 
  public void visitProperty(Configuration configuration, PersistentClass clazz, Property property, IssueCollector collector) {
    if(property.getName().equals("id")) {
      if (property != property.getPersistentClass().getIdentifierProperty()) {
        collector.reportIssue(new Issue("ID_SHADOWED", Issue.LOW_PRIORITY, property.getPersistentClass().getEntityName() + " has a normal property named 'id'. This can cause issues since HQL queries will always interpret 'id' as the identifier and not the concrete property"));
      }
    }
  }
View Full Code Here


      }
      catch (SecurityException e) {
        // ignore
      }
      catch (NoSuchMethodException e) {
        collector.reportIssue(new Issue("LAZY_NO_DEFAULT_CONSTRUCTOR",Issue.NORMAL_PRIORITY, "lazy='true' set for '" + clazz.getEntityName() +"', but class has no default constructor." ));
        return;
      }

    } else if(cglibEnabled || javassistEnabled){
      Class[] interfaces = mappedClass.getInterfaces();
      boolean cglib = false;
      boolean javaassist = false;
      for (int i = 0; i < interfaces.length; i++) {
        Class intface = interfaces[i];       
        if(intface.getName().equals( "net.sf.cglib.transform.impl.InterceptFieldEnabled" )) {
          cglib = true;
        } else if(intface.getName().equals( "org.hibernate.bytecode.javassist.FieldHandled" )) {
          javaassist = true;
        }              
      }
     
      if(cglibEnabled && !cglib) {
        collector.reportIssue( new Issue("LAZY_NOT_INSTRUMENTED", Issue.HIGH_PRIORITY, "'" + clazz.getEntityName() + "' has lazy='false', but its class '" + mappedClass.getName() + "' has not been instrumented with cglib") );
        return;
      } else if (javassistEnabled && !javaassist) {
        collector.reportIssue( new Issue("LAZY_NOT_INSTRUMENTED", Issue.HIGH_PRIORITY, "'" + clazz.getEntityName() + "' has lazy='false', but its class '" + mappedClass.getName() + "' has not been instrumented with javaassist") );
        return;
      } else {
        // unknown bytecodeprovider...can't really check for that.
      }
     
View Full Code Here

    // TODO: move this check into something that could check per class or collection instead.
    while ( iter.hasNext() ) {
      PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
      Object key = generator.generatorKey();
      if ( !isSequence(key, sequences) && !isTable( key ) ) {
        collector.reportIssue( new Issue( "MISSING_ID_GENERATOR", Issue.HIGH_PRIORITY, "Missing sequence or table: " + key));
      }
    }

   
  }
View Full Code Here

      setSchemaSelection( table );

      List list = reader.readDatabaseSchema( dbc, null, null );

      if ( list.isEmpty() ) {
        pc.reportIssue( new Issue( "SCHEMA_TABLE_MISSING",
            Issue.HIGH_PRIORITY, "Missing table "
                + Table.qualify( table.getCatalog(), table
                    .getSchema(), table.getName() ) ) );
        return;
      }
      else if ( list.size() > 1 ) {
        pc.reportIssue( new Issue( "SCHEMA_TABLE_MISSING",
            Issue.NORMAL_PRIORITY, "Found "
                + list.size()
                + " tables for "
                + Table.qualify( table.getCatalog(), table
                    .getSchema(), table.getName() ) ) );
View Full Code Here

    Column dbColumn = currentDbTable
        .getColumn( new Column( col.getName() ) );

    if ( dbColumn == null ) {
      pc.reportIssue( new Issue( "SCHEMA_COLUMN_MISSING",
          Issue.HIGH_PRIORITY, table(table) + " is missing column: " + col.getName() ) );
    }
    else {
      //TODO: this needs to be able to know if a type is truly compatible or not. Right now it requires an exact match.
      //String sqlType = col.getSqlType( dialect, mapping );
      int dbTypeCode = dbColumn.getSqlTypeCode().intValue();
      int modelTypeCode = col
                .getSqlTypeCode( mapping );
      // TODO: sqltype name string
      if ( !(dbTypeCode == modelTypeCode ) ) {
        pc.reportIssue( new Issue( "SCHEMA_COLUMN_TYPE_MISMATCH",
            Issue.NORMAL_PRIORITY, table(table) + " has a wrong column type for "
                + col.getName() + ", expected: "
                + JDBCToHibernateTypeHelper.getJDBCTypeName(modelTypeCode) + " but was " + JDBCToHibernateTypeHelper.getJDBCTypeName(dbTypeCode) + " in db") );
      }
    }
View Full Code Here

          String entityName = (String) col.getElement().accept( new EntityNameFromValueVisitor() );

          if(entityName!=null) {
            PersistentClass classMapping = configuration.getClassMapping( entityName );
            if(classMapping.getCacheConcurrencyStrategy()==null) {
              collector.reportIssue( new Issue("CACHE_COLLECTION_NONCACHABLE_TARGET", Issue.HIGH_PRIORITY, "Entity '" + classMapping.getEntityName() +"' is referenced from the cache-enabled collection '" + col.getRole() + "' without the entity being cachable"));
            }
          }
        }
      }
    } 
View Full Code Here

      }
      catch (SecurityException e) {
        // ignore
      }
      catch (NoSuchMethodException e) {
        collector.reportIssue(new Issue("LAZY_NO_DEFAULT_CONSTRUCTOR",Issue.NORMAL_PRIORITY, "lazy='true' set for '" + clazz.getEntityName() +"', but class has no default constructor." ));
        return;
      }

    } else if(javassistEnabled){
      Class[] interfaces = mappedClass.getInterfaces();
      boolean javaassist = false;
      for (int i = 0; i < interfaces.length; i++) {
        Class intface = interfaces[i];       
        if(intface.getName().equals( "org.hibernate.bytecode.internal.javassist.FieldHandled" )) {
          javaassist = true;
        }              
      }
     
      if (javassistEnabled && !javaassist) {
        collector.reportIssue( new Issue("LAZY_NOT_INSTRUMENTED", Issue.HIGH_PRIORITY, "'" + clazz.getEntityName() + "' has lazy='false', but its class '" + mappedClass.getName() + "' has not been instrumented with javaassist") );
        return;
      } else {
        // unknown bytecodeprovider...can't really check for that.
      }
     
View Full Code Here

    // TODO: move this check into something that could check per class or collection instead.
    while ( iter.hasNext() ) {
      PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
      Object key = generator.generatorKey();
      if ( !isSequence(key, sequences) && !isTable( key ) ) {
        collector.reportIssue( new Issue( "MISSING_ID_GENERATOR", Issue.HIGH_PRIORITY, "Missing sequence or table: " + key));
      }
    }

   
  }
View Full Code Here

      setSchemaSelection( table );

      List list = reader.readDatabaseSchema( dbc, null, null );

      if ( list.isEmpty() ) {
        pc.reportIssue( new Issue( "SCHEMA_TABLE_MISSING",
            Issue.HIGH_PRIORITY, "Missing table "
                + Table.qualify( table.getCatalog(), table
                    .getSchema(), table.getName() ) ) );
        return;
      }
      else if ( list.size() > 1 ) {
        pc.reportIssue( new Issue( "SCHEMA_TABLE_MISSING",
            Issue.NORMAL_PRIORITY, "Found "
                + list.size()
                + " tables for "
                + Table.qualify( table.getCatalog(), table
                    .getSchema(), table.getName() ) ) );
View Full Code Here

    Column dbColumn = currentDbTable
        .getColumn( new Column( col.getName() ) );

    if ( dbColumn == null ) {
      pc.reportIssue( new Issue( "SCHEMA_COLUMN_MISSING",
          Issue.HIGH_PRIORITY, table(table) + " is missing column: " + col.getName() ) );
    }
    else {
      //TODO: this needs to be able to know if a type is truly compatible or not. Right now it requires an exact match.
      //String sqlType = col.getSqlType( dialect, mapping );
      int dbTypeCode = dbColumn.getSqlTypeCode().intValue();
      int modelTypeCode = col
                .getSqlTypeCode( mapping );
      // TODO: sqltype name string
      if ( !(dbTypeCode == modelTypeCode ) ) {
        pc.reportIssue( new Issue( "SCHEMA_COLUMN_TYPE_MISMATCH",
            Issue.NORMAL_PRIORITY, table(table) + " has a wrong column type for "
                + col.getName() + ", expected: "
                + JDBCToHibernateTypeHelper.getJDBCTypeName(modelTypeCode) + " but was " + JDBCToHibernateTypeHelper.getJDBCTypeName(dbTypeCode) + " in db") );
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.tool.hbmlint.Issue

Copyright © 2018 www.massapicom. 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.