Skip to content

Commit

Permalink
fix(deps): update managed.hibernate to v6.4.0.final (#1080)
Browse files Browse the repository at this point in the history
* fix(deps): update managed.hibernate to v6.4.0.final

* Fix the build

* Revert NO_OP to previous impl

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: radovanradic <radicr@gmail.com>
  • Loading branch information
renovate[bot] and radovanradic committed Nov 24, 2023
1 parent cd3ee35 commit 94b10fa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ micronaut-validation = "4.2.0"

managed-vertx = "4.5.0"
managed-jooq = "3.18.7"
managed-hibernate = "6.2.13.Final"
managed-hibernate-reactive = "2.0.6.Final"
managed-hibernate = "6.4.0.Final"
managed-hibernate-reactive = "2.2.0.Final"
managed-jasync = "2.2.4"
managed-jdbi = "3.41.3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.integrator.spi.Integrator;

import static org.hibernate.bytecode.internal.BytecodeProviderInitiator.BYTECODE_PROVIDER_NAME_NONE;
import static org.hibernate.cfg.AvailableSettings.BYTECODE_PROVIDER;

/**
* Default supplier of {@link StandardServiceRegistryBuilderCreator}.
*
Expand All @@ -54,7 +56,7 @@ public DefaultStandardServiceRegistryBuilderCreatorCreator(@Primary @Nullable In
@Override
public StandardServiceRegistryBuilder create(JpaConfiguration jpaConfiguration) {
if (jpaConfiguration.isCompileTimeHibernateProxies()) {
System.setProperty(AvailableSettings.BYTECODE_PROVIDER, org.hibernate.cfg.Environment.BYTECODE_PROVIDER_NAME_NONE);
System.setProperty(BYTECODE_PROVIDER, BYTECODE_PROVIDER_NAME_NONE);
}
if (jpaConfiguration.isReactive()) {
throw new IllegalStateException("Hibernate Reactive not found on classpath!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
package io.micronaut.configuration.hibernate.jpa.proxy;

import io.micronaut.core.annotation.Internal;
import org.hibernate.LazyInitializationException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.AbstractLazyInitializer;

/**
Expand All @@ -43,4 +46,20 @@ public Class<?> getPersistentClass() {
return persistentClass;
}

@Override
public Class<?> getImplementationClass() {
if (!isUninitialized()) {
return getImplementation().getClass();
}
final SharedSessionContractImplementor session = getSession();
if (session == null) {
throw new LazyInitializationException("could not retrieve real entity class [" + getEntityName() + "#" + getIdentifier() + "] - no Session");
}
final SessionFactoryImplementor factory = session.getFactory();
final EntityPersister entityDescriptor = factory.getMappingMetamodel().getEntityDescriptor(getEntityName());
if (entityDescriptor.getEntityMappingType().hasSubclasses()) {
return getImplementation().getClass();
}
return persistentClass;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.micronaut.core.annotation.Internal;
import jakarta.inject.Singleton;
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
import org.hibernate.bytecode.enhance.spi.EnhancementException;
import org.hibernate.bytecode.enhance.spi.Enhancer;
import org.hibernate.bytecode.spi.BytecodeProvider;
import org.hibernate.bytecode.spi.ProxyFactoryFactory;
Expand All @@ -37,7 +38,18 @@
@Internal
public final class IntrospectedHibernateBytecodeProvider implements BytecodeProvider {

private static final Enhancer NO_OP = (className, originalBytes) -> null;
private static final Enhancer NO_OP = new Enhancer() {

@Override
public byte[] enhance(String className, byte[] originalBytes) throws EnhancementException {
return null;
}

@Override
public void discoverTypes(String className, byte[] originalBytes) throws EnhancementException {
// Does nothing
}
};

@Override
public ProxyFactoryFactory getProxyFactoryFactory() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "org.hibernate.dialect.OracleArrayJdbcTypeConstructor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "org.hibernate.dialect.OracleNestedTableJdbcTypeConstructor",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]

0 comments on commit 94b10fa

Please sign in to comment.