HHH-14654 Fix for schema validation bug

This commit is contained in:
Karel Maesen 2021-06-18 13:23:32 +02:00 committed by Christian Beikov
parent bdc08af163
commit 7329f444b5
12 changed files with 74 additions and 0 deletions

View File

@ -42,4 +42,9 @@ public class CockroachDB202SpatialDialect extends CockroachDB201Dialect implemen
delegateContributeTypes( typeContributions, serviceRegistry ); delegateContributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}
} }

View File

@ -74,4 +74,9 @@ public interface CockroachSpatialDialectTrait extends SpatialDialect {
return DELEGATE.supports( function ); return DELEGATE.supports( function );
} }
default boolean isSpatial(int typeCode) {
return DELEGATE.isSpatial( typeCode );
}
} }

View File

@ -7,6 +7,8 @@
package org.hibernate.spatial.dialect.postgis; package org.hibernate.spatial.dialect.postgis;
import java.sql.Types;
import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
import org.hibernate.spatial.dialect.SpatialFunctionsRegistry; import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
@ -125,4 +127,13 @@ interface PGSpatialDialectTrait extends SpatialDialect {
default boolean supports(SpatialFunction function) { default boolean supports(SpatialFunction function) {
return support.supports( function ); return support.supports( function );
} }
/**
* Checks whether the typeCode is (potentially) the code for a spatial type
* @param typeCode the JDBC type code
* @return if the typecode corresponds with a spatialt type
*/
default boolean isSpatial(int typeCode){
return support.isSpatial( typeCode );
}
} }

View File

@ -7,6 +7,7 @@
package org.hibernate.spatial.dialect.postgis; package org.hibernate.spatial.dialect.postgis;
import java.sql.Types;
import java.util.Map; import java.util.Map;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
@ -36,4 +37,11 @@ public class PostgisPG10Dialect extends PostgreSQL10Dialect implements PGSpatial
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}
} }

View File

@ -48,6 +48,11 @@ public class PostgisPG82Dialect extends PostgreSQL82Dialect implements SpatialDi
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
@Override @Override
public String getSpatialRelateSQL(String columnName, int spatialRelation) { public String getSpatialRelateSQL(String columnName, int spatialRelation) {

View File

@ -48,6 +48,12 @@ public class PostgisPG91Dialect extends PostgreSQL91Dialect implements SpatialDi
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s

View File

@ -48,6 +48,12 @@ public class PostgisPG92Dialect extends PostgreSQL92Dialect implements SpatialDi
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s

View File

@ -48,6 +48,12 @@ public class PostgisPG93Dialect extends PostgreSQL93Dialect implements SpatialDi
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s

View File

@ -48,6 +48,12 @@ public class PostgisPG94Dialect extends PostgreSQL94Dialect implements SpatialDi
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s

View File

@ -42,4 +42,9 @@ public class PostgisPG95Dialect extends PostgreSQL95Dialect implements PGSpatial
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}
} }

View File

@ -48,6 +48,12 @@ public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDial
support.contributeTypes( typeContributions, serviceRegistry ); support.contributeTypes( typeContributions, serviceRegistry );
} }
@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( support.isSpatial( typeCode1 ) && support.isSpatial( typeCode2 ) );
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s

View File

@ -7,6 +7,7 @@
package org.hibernate.spatial.dialect.postgis; package org.hibernate.spatial.dialect.postgis;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Types;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
@ -47,6 +48,10 @@ public class PostgisSupport implements SpatialDialect, Serializable {
return postgisFunctions; return postgisFunctions;
} }
public boolean isSpatial(int typeCode){
return typeCode == Types.OTHER || typeCode == PGGeometryTypeDescriptor.INSTANCE_WKB_1.getSqlType();
}
/** /**
* Returns the SQL fragment for the SQL WHERE-clause when parsing * Returns the SQL fragment for the SQL WHERE-clause when parsing
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s * <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s