Skip to content

Commit

Permalink
HHH-17377 - Migrate to JPA 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Nov 17, 2023
1 parent ab4b401 commit a21ac74
Show file tree
Hide file tree
Showing 66 changed files with 527 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;

import jakarta.persistence.criteria.Nulls;

/**
* The contract for building a {@link SessionFactory} given a number of options.
*
Expand Down Expand Up @@ -326,7 +327,7 @@ public interface SessionFactoryBuilder {
*
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_NULL_ORDERING
*/
SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence);
SessionFactoryBuilder applyDefaultNullPrecedence(Nulls nullPrecedence);

/**
* Specify whether ordering of inserts should be enabled.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;

import jakarta.persistence.criteria.Nulls;

/**
* @author Gail Badner
* @author Steve Ebersole
Expand Down Expand Up @@ -238,7 +239,7 @@ public SessionFactoryBuilder applySubselectFetchEnabled(boolean enabled) {
}

@Override
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public SessionFactoryBuilder applyDefaultNullPrecedence(Nulls nullPrecedence) {
this.optionsBuilder.applyDefaultNullPrecedence( nullPrecedence );
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.hql.HqlTranslator;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.internal.NullPrecedenceHelper;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
Expand All @@ -71,6 +71,8 @@
import org.hibernate.type.format.jakartajson.JakartaJsonIntegration;
import org.hibernate.type.format.jaxb.JaxbXmlFormatMapper;

import jakarta.persistence.criteria.Nulls;

import static org.hibernate.cfg.AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS;
import static org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY;
import static org.hibernate.cfg.AvailableSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTION;
Expand Down Expand Up @@ -196,7 +198,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private int defaultBatchFetchSize;
private Integer maximumFetchDepth;
private boolean subselectFetchEnabled;
private NullPrecedence defaultNullPrecedence;
private Nulls defaultNullPrecedence;
private boolean orderUpdatesEnabled;
private boolean orderInsertsEnabled;
private boolean collectionsInDefaultFetchGroupEnabled = true;
Expand Down Expand Up @@ -374,7 +376,7 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
final String defaultNullPrecedence = getString(
AvailableSettings.DEFAULT_NULL_ORDERING, configurationSettings, "none", "first", "last"
);
this.defaultNullPrecedence = NullPrecedence.parse( defaultNullPrecedence );
this.defaultNullPrecedence = NullPrecedenceHelper.parse( defaultNullPrecedence );
this.orderUpdatesEnabled = getBoolean( ORDER_UPDATES, configurationSettings );
this.orderInsertsEnabled = getBoolean( ORDER_INSERTS, configurationSettings );

Expand Down Expand Up @@ -1001,7 +1003,7 @@ public boolean isSubselectFetchEnabled() {
}

@Override
public NullPrecedence getDefaultNullPrecedence() {
public Nulls getDefaultNullPrecedence() {
return defaultNullPrecedence;
}

Expand Down Expand Up @@ -1387,7 +1389,7 @@ public void applySubselectFetchEnabled(boolean subselectFetchEnabled) {
this.subselectFetchEnabled = subselectFetchEnabled;
}

public void applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public void applyDefaultNullPrecedence(Nulls nullPrecedence) {
this.defaultNullPrecedence = nullPrecedence;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.internal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,12 @@ protected <X extends JaxbBindableMappingDescriptor> Binding<X> doBind(
}

final XMLEventReader hbmReader = new HbmEventReader( staxEventReader, xmlEventFactory );
final JaxbHbmHibernateMapping hbmBindings = jaxb( hbmReader, MappingXsdSupport.INSTANCE.hbmXsd()
.getSchema(), hbmJaxbContext(), origin );
final JaxbHbmHibernateMapping hbmBindings = jaxb(
hbmReader,
MappingXsdSupport.INSTANCE.hbmXsd().getSchema(),
hbmJaxbContext(),
origin
);

if ( optionsAccess.get().transformHbmMappings() ) {
JaxbLogger.JAXB_LOGGER.tracef( "Performing on-the-fly hbm.xml -> mapping.xml transformation - %s ", origin );
Expand All @@ -230,8 +234,12 @@ protected <X extends JaxbBindableMappingDescriptor> Binding<X> doBind(
log.debugf( "Performing JAXB binding of orm.xml document : %s", origin.toString() );

final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
final JaxbEntityMappingsImpl bindingRoot = jaxb( reader, MappingXsdSupport.latestDescriptor()
.getSchema(), mappingJaxbContext(), origin );
final JaxbEntityMappingsImpl bindingRoot = jaxb(
reader,
MappingXsdSupport.latestDescriptor().getSchema(),
mappingJaxbContext(),
origin
);
//noinspection unchecked
return new Binding<>( (X) bindingRoot, origin );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElem
}

private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
// Here we look to see if this attribute is the JPA version attribute, and if so do 2 things:
// 1) validate its version attribute is valid
// 2) update its version attribute to the default version if not already
// Here we look to see if this attribute is the JPA version attribute, and if so do 3 things:
// 1) validate its version attribute is valid per our "latest XSD"
// 2) update its version attribute to the latest version if not already
// 3) if the latest XSD version is not in the XML list of valid versions, add it to avoid validation errors
//
// NOTE : atm this is a very simple check using just the attribute's local name
// rather than checking its qualified name. It is possibly (though unlikely)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
* 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.boot.jaxb.mapping.spi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.type.format.FormatMapper;

import jakarta.persistence.criteria.Nulls;

/**
* Convenience base class for custom implementors of SessionFactoryBuilder, using delegation
*
Expand Down Expand Up @@ -186,7 +187,7 @@ public SessionFactoryBuilder applySubselectFetchEnabled(boolean enabled) {
}

@Override
public T applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
public T applyDefaultNullPrecedence(Nulls nullPrecedence) {
delegate.applyDefaultNullPrecedence( nullPrecedence );
return getThis();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.hql.HqlTranslator;
import org.hibernate.query.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
Expand All @@ -38,6 +37,8 @@
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.format.FormatMapper;

import jakarta.persistence.criteria.Nulls;

/**
* Convenience base class for custom implementations of {@link SessionFactoryOptions}
* using delegation.
Expand Down Expand Up @@ -194,7 +195,7 @@ public boolean isSubselectFetchEnabled() {
}

@Override
public NullPrecedence getDefaultNullPrecedence() {
public Nulls getDefaultNullPrecedence() {
return delegate.getDefaultNullPrecedence();
}

Expand Down

0 comments on commit a21ac74

Please sign in to comment.