Skip to content

Commit

Permalink
TODOTICKET Upgrade to Hibernate ORM 6.2.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Jan 2, 2023
1 parent 45c7d6f commit c5a1265
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 21 deletions.
Expand Up @@ -20,8 +20,6 @@

import org.hibernate.Hibernate;
import org.hibernate.SessionFactory;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
Expand Down Expand Up @@ -138,7 +136,6 @@ public static class Group {
private int someInteger;

@OneToMany(mappedBy = "group")
@LazyCollection(LazyCollectionOption.EXTRA)
private Set<Post> posts = new HashSet<>();

public Integer getId() {
Expand Down
Expand Up @@ -25,8 +25,6 @@
import jakarta.persistence.OrderColumn;
import jakarta.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock;
Expand Down Expand Up @@ -130,7 +128,6 @@ public static class Post {
private String name;

@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyCollection(LazyCollectionOption.EXTRA)
@OrderColumn(name = "idx")
private List<Comment> comments = new ArrayList<>();

Expand Down
Expand Up @@ -1129,10 +1129,10 @@ public void afterLast_fromAfterLast() {
public void close() {
setupHolder.runInTransaction( session -> {
expectScrollCreate();
try ( ScrollableResults<?> scroll = createSimpleQuery( session ).scroll() ) {
try ( ScrollableResults<IndexedEntity> scroll = createSimpleQuery( session ).scroll() ) {
backendMock.verifyExpectationsMet();

ScrollableResultsImplementor implementor = (ScrollableResultsImplementor) scroll;
ScrollableResultsImplementor<IndexedEntity> implementor = (ScrollableResultsImplementor<IndexedEntity>) scroll;

assertThat( implementor.isClosed() ).isFalse();

Expand Down
Expand Up @@ -284,11 +284,14 @@ public static class IndexedEntity
extends IndexedEntitySuperClass {
public static final String INDEX = "IndexedEntity";

// "containedEntityList" is not listed here,
// because collection properties are initialized eagerly
// (even if the collection themselves are initialized lazily).
// See HHH-15473 / https://github.com/hibernate/hibernate-orm/pull/5252
private static final String[] LAZY_PROPERTY_NAMES = new String[] {
"mappedSuperClassText",
"entitySuperClassText",
"notIndexedText",
"containedEntityList",
"text1",
"text2",
"primitiveInteger",
Expand Down
Expand Up @@ -46,7 +46,7 @@ private PersistenceUtil() {
*/
public static Session openSession(EntityManagerFactory entityManagerFactory, String tenantId) {
SessionFactory sessionFactory = entityManagerFactory.unwrap( SessionFactory.class );
SessionBuilder<?> builder = sessionFactory.withOptions();
SessionBuilder builder = sessionFactory.withOptions();
if ( StringHelper.isNotEmpty( tenantId ) ) {
builder.tenantIdentifier( tenantId );
}
Expand Down
Expand Up @@ -78,7 +78,7 @@ protected List<OutboxEvent> tryLoadLocking(Session session, Set<UUID> ids) {
Query<OutboxEvent> query = session.createQuery( LOAD_QUERY, OutboxEvent.class );
query.setParameter( "ids", ids );

query.setLockOptions( new LockOptions( LockMode.PESSIMISTIC_WRITE ).setTimeOut( LockOptions.SKIP_LOCKED ) );
query.setLockOptions( new LockOptions( LockMode.UPGRADE_SKIPLOCKED ) );

return query.getResultList();
}
Expand Down
Expand Up @@ -108,8 +108,7 @@ public static EntityPersister toMostSpecificCommonEntitySuperType(EntityPersiste

public static boolean targetsAllConcreteSubTypes(SessionFactoryImplementor sessionFactory,
EntityPersister parentType, Collection<?> targetConcreteSubTypes) {
@SuppressWarnings("unchecked")
Set<String> subClassEntityNames = parentType.getEntityMetamodel().getSubclassEntityNames();
Set<String> subClassEntityNames = parentType.getEntityMappingType().getSubclassEntityNames();
// Quick check to return true immediately if all subtypes are concrete
if ( subClassEntityNames.size() == targetConcreteSubTypes.size() ) {
return true;
Expand Down
Expand Up @@ -299,7 +299,7 @@ private void processCollectionEvent(AbstractCollectionEvent event) {

BitSet dirtyPaths;
if ( dirtyCheckingEnabled ) {
PersistentCollection persistentCollection = event.getCollection();
PersistentCollection<?> persistentCollection = event.getCollection();
String collectionRole = null;
if ( persistentCollection != null ) {
collectionRole = persistentCollection.getRole();
Expand Down
Expand Up @@ -235,12 +235,12 @@ public HibernateOrmSearchQueryAdapter<R> setParameterList(String name, Object[]
}

@Override
public QueryImplementor<R> setParameterList(String s, Collection collection, Class aClass) {
public <P> QueryImplementor<R> setParameterList(String s, Collection<? extends P> collection, Class<P> aClass) {
throw parametersNoSupported();
}

@Override
public QueryImplementor<R> setParameterList(int i, Collection collection, Class aClass) {
public <P> QueryImplementor<R> setParameterList(int i, Collection<? extends P> collection, Class<P> aClass) {
throw parametersNoSupported();
}

Expand All @@ -249,12 +249,12 @@ private UnsupportedOperationException parametersNoSupported() {
}

@Override
public QueryImplementor<R> setTupleTransformer(TupleTransformer transformer) {
public <T> QueryImplementor<T> setTupleTransformer(TupleTransformer<T> transformer) {
throw resultOrTupleTransformerNotImplemented();
}

@Override
public QueryImplementor<R> setResultListTransformer(ResultListTransformer resultListTransformer) {
public QueryImplementor<R> setResultListTransformer(ResultListTransformer<R> resultListTransformer) {
throw resultOrTupleTransformerNotImplemented();
}

Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Expand Up @@ -260,9 +260,10 @@
<version.org.jboss.jandex>2.4.2.Final</version.org.jboss.jandex>
<version.org.hibernate.commons.annotations>${version.org.hibernate.commons.annotations.orm6}</version.org.hibernate.commons.annotations>
<version.net.bytebuddy>${version.net.bytebuddy.orm6}</version.net.bytebuddy>
<version.io.smallrye.jandex>3.0.0</version.io.smallrye.jandex>

<!-- >>> ORM 6 / Jakarta Persistence -->
<version.org.hibernate.orm>6.1.6.Final</version.org.hibernate.orm>
<version.org.hibernate.orm>6.2.0-SNAPSHOT</version.org.hibernate.orm>
<javadoc.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/javadocs/</javadoc.org.hibernate.orm.url>
<documentation.org.hibernate.orm.url>https://docs.jboss.org/hibernate/orm/${parsed-version.org.hibernate.orm.majorVersion}.${parsed-version.org.hibernate.orm.minorVersion}/userguide/html_single/Hibernate_User_Guide.html</documentation.org.hibernate.orm.url>
<!-- These version must be kept in sync with the version of the dependency in Hibernate ORM 6.
Expand All @@ -272,10 +273,10 @@
and to our own explicit dependencies in the relevant artifacts.
-->
<version.org.hibernate.commons.annotations.orm6>6.0.5.Final</version.org.hibernate.commons.annotations.orm6>
<version.jakarta.persistence>3.0.0</version.jakarta.persistence>
<version.jakarta.persistence>3.1.0</version.jakarta.persistence>
<version.jakarta.enterprise>3.0.1</version.jakarta.enterprise>
<version.jakarta.xml.bind>3.0.1</version.jakarta.xml.bind>
<version.net.bytebuddy.orm6>1.12.9</version.net.bytebuddy.orm6>
<version.net.bytebuddy.orm6>1.12.18</version.net.bytebuddy.orm6>

<!-- >>> JSR 352 -->
<version.jakarta.batch>2.1.1</version.jakarta.batch>
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.hibernate.tool.schema.internal.SchemaDropperImpl;
import org.hibernate.tool.schema.internal.exec.GenerationTarget;
import org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase;
import org.hibernate.tool.schema.internal.exec.JdbcContext;
import org.hibernate.tool.schema.spi.ContributableMatcher;
import org.hibernate.tool.schema.spi.DelayedDropAction;
import org.hibernate.tool.schema.spi.ExecutionOptions;
Expand All @@ -29,6 +30,7 @@
import org.hibernate.tool.schema.spi.SchemaDropper;
import org.hibernate.tool.schema.spi.SchemaManagementTool;
import org.hibernate.tool.schema.spi.SchemaMigrator;
import org.hibernate.tool.schema.spi.SchemaTruncator;
import org.hibernate.tool.schema.spi.SchemaValidator;
import org.hibernate.tool.schema.spi.SourceDescriptor;
import org.hibernate.tool.schema.spi.TargetDescriptor;
Expand Down Expand Up @@ -134,6 +136,11 @@ public SchemaValidator getSchemaValidator(Map<String,Object> options) {
throw notSupported();
}

@Override
public SchemaTruncator getSchemaTruncator(Map<String, Object> options) {
throw notSupported();
}

@Override
public void setCustomDatabaseGenerationTarget(GenerationTarget generationTarget) {
throw notSupported();
Expand All @@ -144,6 +151,12 @@ public ExtractionTool getExtractionTool() {
throw notSupported();
}

@Override
public GenerationTarget[] buildGenerationTargets(TargetDescriptor targetDescriptor, JdbcContext jdbcContext,
Map<String, Object> options, boolean needsAutoCommit) {
throw notSupported();
}

private UnsupportedOperationException notSupported() {
return new UnsupportedOperationException(
"This feature is not supported when simulating multi-tenancy with test helpers" );
Expand Down

0 comments on commit c5a1265

Please sign in to comment.