IncomparableTypeUsedInComparison.java

  1. /*
  2.  * Copyright 2015 gregory.graham.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package nz.co.gregs.dbvolution.exceptions;

  17. import nz.co.gregs.dbvolution.databases.definitions.DBDefinition;
  18. import nz.co.gregs.dbvolution.expressions.DBExpression;

  19. /**
  20.  * Thrown when the datatype used in a comparison does not support that
  21.  * comparison.
  22.  *
  23.  * <p>
  24.  * Theoretically no-one should ever see this exception but mistakes do happen.
  25.  *
  26.  * <p>
  27.  * If it occurs check that you're not accidentally comparing LargeObject columns
  28.  * (JavaObject, CLOB, BLOB, etc) as they support very few comparisons.
  29.  *
  30.  * <p>
  31.  * Alternatively inform the developers and they will fix it.
  32.  *
  33.  * <p style="color: #F90;">Support DBvolution at
  34.  * <a href="http://patreon.com/dbvolution" target=new>Patreon</a></p>
  35.  *
  36.  * @author Gregory Graham
  37.  */
  38. public class IncomparableTypeUsedInComparison extends DBRuntimeException {

  39.     private static final long serialVersionUID = 1L;

  40.     /**
  41.      * Thrown when the datatype used in a comparison does not support that
  42.      * comparison.
  43.      *
  44.      * <p>
  45.      * Theoretically no-one should ever see this exception but mistakes do happen.
  46.      *
  47.      * <p>
  48.      * If it occurs check that you're not accidentally comparing LargeObject
  49.      * columns (JavaObject, CLOB, BLOB, etc) as they support very few comparisons.
  50.      *
  51.      * <p>
  52.      * Alternatively inform the developers and they will fix it.
  53.      *
  54.      * @param db the database definition
  55.      * @param genericExpression the expression that is not capable of being compared with equals
  56.      */
  57.     public IncomparableTypeUsedInComparison(DBDefinition db, DBExpression genericExpression) {
  58.         super("Incomparable Type: " + genericExpression.toSQLString(db) + " is a " + genericExpression.getClass().getSimpleName() + " and is not an equals comparable expression");
  59.     }

  60. }