Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">

<persistence-unit name="postgresql-example">
<persistence-unit name="postgresql-example">
<provider>org.hibernate.reactive.provider.ReactivePersistenceProvider</provider>

<class>org.hibernate.reactive.example.nativesql.Author</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">

<persistence-unit name="postgresql-example">
<persistence-unit name="postgresql-example">
<provider>org.hibernate.reactive.provider.ReactivePersistenceProvider</provider>

<class>org.hibernate.reactive.example.session.Author</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package org.hibernate.reactive.stage.impl;

import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.concurrent.CompletionStage;

Expand All @@ -16,8 +15,6 @@
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.query.Order;
import org.hibernate.query.Page;
import org.hibernate.reactive.logging.impl.Log;
import org.hibernate.reactive.logging.impl.LoggerFactory;
import org.hibernate.reactive.query.ReactiveSelectionQuery;
import org.hibernate.reactive.stage.Stage.SelectionQuery;

Expand All @@ -29,7 +26,6 @@
import jakarta.persistence.Parameter;

public class StageSelectionQueryImpl<T> implements SelectionQuery<T> {
private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
private final ReactiveSelectionQuery<T> delegate;

public StageSelectionQueryImpl(ReactiveSelectionQuery<T> delegate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.List;

Expand All @@ -29,8 +30,11 @@
import static org.hibernate.cfg.AvailableSettings.TIMEZONE_DEFAULT_STORAGE;
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat;
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;

/**
* Test adapted from {@link org.hibernate.orm.test.timezones.AutoZonedTest}
*/
@Timeout(value = 10, timeUnit = MINUTES)
@DisabledFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0")
public class AutoZonedTest extends BaseReactiveTest {
Expand All @@ -48,8 +52,16 @@ protected void setProperties(Configuration configuration) {

@Test
public void test(VertxTestContext context) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of( "CET" ) );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours( 3 ) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( getDialect().getDefaultTimestampPrecision() == 6 ) {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") ).truncatedTo( ChronoUnit.MICROS );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) ).truncatedTo( ChronoUnit.MICROS );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
test( context, getSessionFactory()
.withTransaction( s -> {
Zoned z = new Zoned();
Expand All @@ -60,10 +72,10 @@ public void test(VertxTestContext context) {
.thenCompose( zid -> openSession()
.thenCompose( s -> s.find( Zoned.class, zid )
.thenAccept( z -> {
assertWithTruncationThat( roundToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( roundToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertThat( z.zonedDateTime.toOffsetDateTime().getOffset() )
.isEqualTo( nowZoned.toOffsetDateTime().getOffset() );
assertThat( z.offsetDateTime.getOffset() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.List;

Expand All @@ -29,8 +30,11 @@
import static org.hibernate.cfg.AvailableSettings.TIMEZONE_DEFAULT_STORAGE;
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat;
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;

/**
* Test adapted from {@link org.hibernate.orm.test.timezones.ColumnZonedTest}
*/
@Timeout(value = 10, timeUnit = MINUTES)
@DisabledFor(value = DB2, reason = "java.sql.SQLException: An error occurred with a DB2 operation, SQLCODE=-180 SQLSTATE=22007")
public class ColumnZonedTest extends BaseReactiveTest {
Expand All @@ -48,8 +52,16 @@ protected void setProperties(Configuration configuration) {

@Test
public void test(VertxTestContext context) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of( "CET" ) );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours( 3 ) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( getDialect().getDefaultTimestampPrecision() == 6 ) {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") ).truncatedTo( ChronoUnit.MICROS );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) ).truncatedTo( ChronoUnit.MICROS );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
test( context, getSessionFactory()
.withTransaction( s -> {
Zoned z = new Zoned();
Expand All @@ -60,10 +72,10 @@ public void test(VertxTestContext context) {
.thenCompose( zid -> openSession()
.thenCompose( s -> s.find( Zoned.class, zid )
.thenAccept( z -> {
assertWithTruncationThat( roundToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( roundToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertThat( z.zonedDateTime.toOffsetDateTime().getOffset() )
.isEqualTo( nowZoned.toOffsetDateTime().getOffset() );
assertThat( z.offsetDateTime.getOffset() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.List;

Expand All @@ -28,8 +29,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat;
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;

/**
* Test adapted from {@link org.hibernate.orm.test.timezones.DefaultZonedTest}
*/
@Timeout(value = 10, timeUnit = MINUTES)
@DisabledFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0")
public class DefaultZonedTest extends BaseReactiveTest {
Expand All @@ -41,8 +45,16 @@ protected Collection<Class<?>> annotatedEntities() {

@Test
public void test(VertxTestContext context) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of( "CET" ) );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours( 3 ) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( getDialect().getDefaultTimestampPrecision() == 6 ) {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") ).truncatedTo( ChronoUnit.MICROS );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) ).truncatedTo( ChronoUnit.MICROS );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
test( context, getSessionFactory()
.withTransaction( s -> {
Zoned z = new Zoned();
Expand All @@ -53,10 +65,10 @@ public void test(VertxTestContext context) {
.thenCompose( zid -> openSession()
.thenCompose( s -> s.find( Zoned.class, zid )
.thenAccept( z -> {
assertWithTruncationThat( roundToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( roundToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );

if ( getDialect().getTimeZoneSupport() == TimeZoneSupport.NATIVE ) {
assertThat( z.zonedDateTime.toOffsetDateTime().getOffset() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.List;

Expand All @@ -31,8 +32,11 @@
import static org.hibernate.cfg.AvailableSettings.TIMEZONE_DEFAULT_STORAGE;
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat;
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;

/**
* Test adapted from {@link org.hibernate.orm.test.timezones.JDBCTimeZoneZonedTest}
*/
@Timeout(value = 10, timeUnit = MINUTES)
@DisabledFor(value = DB2, reason = "Exception: IllegalStateException: Needed to have 6 in buffer but only had 0")
public class JDBCTimeZoneZonedTest extends BaseReactiveTest {
Expand All @@ -51,8 +55,16 @@ protected void setProperties(Configuration configuration) {

@Test
public void test(VertxTestContext context) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of( "CET" ) );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours( 3 ) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( getDialect().getDefaultTimestampPrecision() == 6 ) {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") ).truncatedTo( ChronoUnit.MICROS );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) ).truncatedTo( ChronoUnit.MICROS );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
test( context, getSessionFactory()
.withTransaction( s -> {
Zoned z = new Zoned();
Expand All @@ -63,11 +75,11 @@ public void test(VertxTestContext context) {
.thenCompose( zid -> openSession()
.thenCompose( s -> s.find( Zoned.class, zid )
.thenAccept( z -> {
assertWithTruncationThat( roundToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );

assertWithTruncationThat( roundToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );

ZoneId systemZone = ZoneId.systemDefault();
ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collection;
import java.util.List;

Expand All @@ -30,8 +31,11 @@
import static org.hibernate.cfg.AvailableSettings.TIMEZONE_DEFAULT_STORAGE;
import static org.hibernate.reactive.testing.ReactiveAssertions.assertWithTruncationThat;
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2;
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;

/**
* Test adapted from {@link org.hibernate.orm.test.timezones.PassThruZonedTest}
*/
@Timeout(value = 10, timeUnit = MINUTES)
@DisabledFor(value = DB2, reason = "Exception: SQLException: An error occurred with a DB2 operation, SQLCODE=-180 SQLSTATE=22007")
public class PassThruZonedTest extends BaseReactiveTest {
Expand All @@ -49,8 +53,16 @@ protected void setProperties(Configuration configuration) {

@Test
public void test(VertxTestContext context) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of( "CET" ) );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours( 3 ) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( getDialect().getDefaultTimestampPrecision() == 6 ) {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") ).truncatedTo( ChronoUnit.MICROS );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) ).truncatedTo( ChronoUnit.MICROS );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
test( context, getSessionFactory()
.withTransaction( s -> {
Zoned z = new Zoned();
Expand All @@ -61,10 +73,10 @@ public void test(VertxTestContext context) {
.thenCompose( zid -> openSession()
.thenCompose( s -> s.find( Zoned.class, zid )
.thenAccept( z -> {
assertWithTruncationThat( roundToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( roundToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( roundToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.zonedDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowZoned.toInstant(), getDialect() ) );
assertWithTruncationThat( adjustToDefaultPrecision( z.offsetDateTime.toInstant(), getDialect() ) )
.isEqualTo( adjustToDefaultPrecision( nowOffset.toInstant(), getDialect() ) );

ZoneId systemZone = ZoneId.systemDefault();
ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() );
Expand Down
Loading