code: private void checkForGenerator(final Class<?> clazz, Field field, GeneratedValue generatedValue, String schemaName)
  
      {
  
          TableGenerator tableGenerator = field.getAnnotation(TableGenerator.class);
          SequenceGenerator sequenceGenerator = field.getAnnotation(SequenceGenerator.class);
          if (tableGenerator == null || !tableGenerator.name().equals(generatedValue.generator()))
          {
              tableGenerator = clazz.getAnnotation(TableGenerator.class);
          }
          if (sequenceGenerator == null || !sequenceGenerator.name().equals(generatedValue.generator()))
          {
              sequenceGenerator = clazz.getAnnotation(SequenceGenerator.class);
          }
  
          if ((tableGenerator == null && sequenceGenerator == null)
                  || (tableGenerator != null && !tableGenerator.name().equals(generatedValue.generator()))
                  || (sequenceGenerator != null && !sequenceGenerator.name().equals(generatedValue.generator())))
          {
  
              throw new RuleValidationException("Unknown Id.generator: " + generatedValue.generator());
  
          }
          else if ((tableGenerator != null && !tableGenerator.schema().isEmpty() && !tableGenerator.schema().equals(
                  schemaName))
                  || (sequenceGenerator != null && !sequenceGenerator.schema().isEmpty() && !sequenceGenerator.schema()
                          .equals(schemaName)))
          {
  
              throw new RuleValidationException("Generator " + generatedValue.generator() + " in entity : "
                      + clazz.getName() + " has different schema name ,it should be same as entity have");
  
          }
  
      }
docs: Validate for generator.
  
  @param clazz
  @param field
  @param generatedValue
  @param schemaName
  @throws RuleValidationException