-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-15669 Fix test failures when using Oracle 21
Rings in Oracle polygons may be shifted depending on how it is processed. The equality test now takes this into account. Add test to investigate st_within test failure.
- Loading branch information
Showing
13 changed files
with
325 additions
and
200 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
...-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/hhh15669/TestStWithinBug.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
|
||
package org.hibernate.spatial.dialect.oracle.hhh15669; | ||
|
||
|
||
import java.util.List; | ||
|
||
import org.hibernate.dialect.OracleDialect; | ||
import org.hibernate.spatial.HibernateSpatialConfigurationSettings; | ||
import org.hibernate.spatial.testing.SpatialSessionFactoryAware; | ||
|
||
import org.hibernate.testing.TestForIssue; | ||
import org.hibernate.testing.orm.junit.DomainModel; | ||
import org.hibernate.testing.orm.junit.RequiresDialect; | ||
import org.hibernate.testing.orm.junit.ServiceRegistry; | ||
import org.hibernate.testing.orm.junit.SessionFactory; | ||
import org.hibernate.testing.orm.junit.Setting; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import org.geolatte.geom.G2D; | ||
import org.geolatte.geom.Point; | ||
import org.geolatte.geom.Polygon; | ||
|
||
import static org.geolatte.geom.builder.DSL.g; | ||
import static org.geolatte.geom.builder.DSL.point; | ||
import static org.geolatte.geom.builder.DSL.polygon; | ||
import static org.geolatte.geom.builder.DSL.ring; | ||
import static org.geolatte.geom.crs.CoordinateReferenceSystems.WGS84; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; | ||
|
||
@TestForIssue(jiraKey = "HHH-15669") | ||
@DomainModel(annotatedClasses = { Foo.class }) | ||
@RequiresDialect(value = OracleDialect.class) | ||
@SessionFactory | ||
@ServiceRegistry(settings = { | ||
@Setting(name = HibernateSpatialConfigurationSettings.ORACLE_OGC_STRICT, value = "true") | ||
}) | ||
public class TestStWithinBug extends SpatialSessionFactoryAware { | ||
Polygon<G2D> filter = polygon( WGS84, ring( | ||
g( 0, 0 ), | ||
g( 10, 0 ), | ||
g( 10, 10 ), | ||
g( 0, 10 ), | ||
g( 0, 0 ) | ||
) ); | ||
|
||
@BeforeEach | ||
public void before() { | ||
scope.inTransaction( | ||
session -> { | ||
session.persist( new Foo( 1, point( WGS84, g( 5, 5 ) ) ) ); | ||
session.persist( new Foo( 2, point( WGS84, g( 12, 12 ) ) ) ); | ||
session.persist( new Foo( 3, point( WGS84, g( -1, -1 ) ) ) ); | ||
} | ||
); | ||
} | ||
|
||
|
||
@Test | ||
public void testHql() { | ||
scope.inTransaction( session -> { | ||
|
||
List<Foo> list = session | ||
.createQuery( "from Foo where st_within(point, :filter) = true", Foo.class ) | ||
.setParameter( "filter", filter ) | ||
.getResultList(); | ||
assertThat( list, hasSize( 1 ) ); | ||
assertThat( list.get( 0 ).id, equalTo( 1L ) ); | ||
} ); | ||
} | ||
|
||
|
||
@AfterEach | ||
public void cleanup() { | ||
scope.inTransaction( session -> session.createMutationQuery( "delete from Foo" ) | ||
.executeUpdate() ); | ||
} | ||
|
||
} | ||
|
||
@Entity(name = "Foo") | ||
@Table(name = "Foo") | ||
class Foo { | ||
@Id | ||
long id; | ||
Point<G2D> point; | ||
|
||
public Foo() { | ||
} | ||
|
||
public Foo(long id, Point<G2D> point) { | ||
this.id = id; | ||
this.point = point; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
hibernate-spatial/src/test/java/org/hibernate/spatial/testing/GeometryEquality.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.