Skip to content

Commit

Permalink
HHH-14654 Fix for schema validation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
maesenka authored and beikov committed Jun 21, 2021
1 parent bdc08af commit 7329f44
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
delegateContributeTypes( typeContributions, serviceRegistry );
}

@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ default boolean supports(SpatialFunction function) {
return DELEGATE.supports( function );
}


default boolean isSpatial(int typeCode) {
return DELEGATE.isSpatial( typeCode );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package org.hibernate.spatial.dialect.postgis;

import java.sql.Types;

import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction;
import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
Expand Down Expand Up @@ -125,4 +127,13 @@ default boolean supportsFiltering() {
default boolean supports(SpatialFunction 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 );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.hibernate.spatial.dialect.postgis;

import java.sql.Types;
import java.util.Map;

import org.hibernate.boot.model.TypeContributions;
Expand Down Expand Up @@ -36,4 +37,11 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
support.contributeTypes( typeContributions, serviceRegistry );
}

@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public void contributeTypes(TypeContributions 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
public String getSpatialRelateSQL(String columnName, int spatialRelation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void contributeTypes(TypeContributions 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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void contributeTypes(TypeContributions 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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void contributeTypes(TypeContributions 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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void contributeTypes(TypeContributions 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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
support.contributeTypes( typeContributions, serviceRegistry );
}

@Override
public boolean equivalentTypes(int typeCode1, int typeCode2) {
return super.equivalentTypes( typeCode1, typeCode2 ) ||
( isSpatial( typeCode1 ) && isSpatial( typeCode2 ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void contributeTypes(TypeContributions 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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package org.hibernate.spatial.dialect.postgis;

import java.io.Serializable;
import java.sql.Types;

import org.hibernate.boot.model.TypeContributions;
import org.hibernate.service.ServiceRegistry;
Expand Down Expand Up @@ -47,6 +48,10 @@ public SpatialFunctionsRegistry functionsToRegister() {
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
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
Expand Down

0 comments on commit 7329f44

Please sign in to comment.