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 @@ -13,6 +13,7 @@
import org.hibernate.annotations.Generated;
import org.hibernate.cfg.AvailableSettings;

import org.hibernate.community.dialect.InformixDialect;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
Expand Down Expand Up @@ -82,7 +83,7 @@ public void testUpdate(SessionFactoryScope scope) {
entities.forEach( ge -> ge.setName( "updated" ) );

//We need to wait a little to make sure the timestamps produced are different
waitALittle();
waitALittle( scope );
session.flush(); // force update and retrieval of generated values

entities.forEach( ge -> assertThat( ge.getName() ).isEqualTo( "updated" ) );
Expand Down Expand Up @@ -129,9 +130,13 @@ public Instant getUpdateTimestamp() {
}
}

private static void waitALittle() {
private static void waitALittle(SessionFactoryScope scope) {
boolean waitLonger =
// informix clock has low resolution on Mac
scope.getSessionFactory().getJdbcServices().getDialect()
instanceof InformixDialect;
try {
Thread.sleep( 10 );
Thread.sleep( waitLonger ? 1_200 : 10 );
}
catch (InterruptedException e) {
throw new HibernateError( "Unexpected wakeup from test sleep" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import java.util.List;
import java.util.Locale;

import org.hibernate.HibernateError;
import org.hibernate.annotations.CurrentTimestamp;

import org.hibernate.community.dialect.InformixDialect;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.Jira;
Expand Down Expand Up @@ -77,6 +79,8 @@ public void testUpdate(SessionFactoryScope scope) {
assertThat( pizza.getLastUpdated() ).isEqualTo( updatedTime );
} );

waitALittle( scope );

scope.inTransaction( session -> {
final Pizza pizza = session.find( Pizza.class, 1L );
assertThat( pizza.getToppings() ).hasSize( 3 )
Expand Down Expand Up @@ -177,4 +181,17 @@ public void setPizza(final Pizza pizza) {
}

}

private static void waitALittle(SessionFactoryScope scope) {
boolean waitLonger =
// informix clock has low resolution on Mac
scope.getSessionFactory().getJdbcServices().getDialect()
instanceof InformixDialect;
try {
Thread.sleep( waitLonger ? 1_200 : 2 );
}
catch (InterruptedException e) {
throw new HibernateError( "Unexpected wakeup from test sleep" );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.List;

import org.hibernate.community.dialect.InformixDialect;
import org.hibernate.dialect.SybaseASEDialect;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
Expand All @@ -19,8 +20,8 @@
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.SkipForDialect;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import jakarta.persistence.Entity;
Expand All @@ -47,7 +48,7 @@
} )
@SessionFactory
public class CriteriaMultiselectGroupByAndOrderByTest {
@BeforeAll
@BeforeEach
public void setUp(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final Secondary secondaryA = new Secondary( 1, "a" );
Expand All @@ -69,12 +70,9 @@ public void setUp(SessionFactoryScope scope) {
} );
}

@AfterAll
@AfterEach
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction( session -> {
session.createMutationQuery( "delete from Primary" ).executeUpdate();
session.createMutationQuery( "delete from Secondary" ).executeUpdate();
} );
scope.getSessionFactory().getSchemaManager().truncate();
}

@Test
Expand Down Expand Up @@ -129,14 +127,20 @@ public void testSubqueryGroupBy(SessionFactoryScope scope) {

@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-17231" )
@SkipForDialect( dialectClass = SybaseASEDialect.class, reason = "Sybase doesn't support order by + offset in subqueries")
@SkipForDialect( dialectClass = SybaseASEDialect.class,
reason = "Sybase doesn't support order by + offset in subqueries")
@SkipForDialect( dialectClass = InformixDialect.class,
reason = "Informix doesn't support offset in subqueries")
public void testSubqueryGroupByAndOrderBy(SessionFactoryScope scope) {
executeSubquery( scope, true, false );
}

@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-17231" )
@SkipForDialect( dialectClass = SybaseASEDialect.class, reason = "Sybase doesn't support order by + offset in subqueries")
@SkipForDialect( dialectClass = SybaseASEDialect.class,
reason = "Sybase doesn't support order by + offset in subqueries")
@SkipForDialect( dialectClass = InformixDialect.class,
reason = "Informix doesn't support offset in subqueries")
public void testSubqueryGroupByAndOrderByAndHaving(SessionFactoryScope scope) {
executeSubquery( scope, true, true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
</set>

<sql-query name="all">
<return alias="item" class="Item"/>
<return-join alias="bid" property="item.bids"/>
<return-join alias="commnt" property="item.comments"/>
select {item.*}, {bid.*}, {commnt.*}
from AuctionItems item
left outer join AuctionBids bid on bid.item = item.id
left outer join AuctionComments commnt on commnt.item = item.id
<return alias="it" class="Item"/>
<return-join alias="bid" property="it.bids"/>
<return-join alias="commnt" property="it.comments"/>
select {it.*}, {bid.*}, {commnt.*}
from AuctionItems it
left outer join AuctionBids bid on bid.item = it.id
left outer join AuctionComments commnt on commnt.item = it.id
</sql-query>

</class>
Expand Down