Avoid warnings on bean validation as we don't use it in JPA

Closes #16502

---
Quarkus3 branch sync no. 6 (17.2.2023)
Resolved conflicts:
keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java - Modified
---
Quarkus3 branch sync no. 3 (27.1.2023)
Resolved conflicts:
keycloak/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/JpaMapStorageProviderFactory.java - Modified
This commit is contained in:
Alexander Schwartz 2023-01-17 16:37:59 +01:00 committed by Václav Muzikář
parent 386c58c78b
commit 33e2bcd94f
2 changed files with 4 additions and 0 deletions

View file

@ -17,6 +17,7 @@
package org.keycloak.connections.jpa.util;
import jakarta.persistence.ValidationMode;
import org.jboss.logging.Logger;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
@ -70,6 +71,7 @@ public class JpaUtils {
// Now build the entity manager factory, supplying a proxy classloader, so Hibernate will be able
// to find and load the extra provided entities.
persistenceUnit.setTransactionType(txType);
persistenceUnit.setValidationMode(ValidationMode.NONE.name());
return Bootstrap.getEntityManagerFactoryBuilder(persistenceUnit, properties,
new ProxyClassLoader(providedEntities)).build();
}

View file

@ -36,6 +36,7 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.ValidationMode;
import jakarta.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource;
import jakarta.transaction.HeuristicMixedException;
@ -410,6 +411,7 @@ public class JpaMapStorageProviderFactory implements
properties.put("hibernate.dialect", config.get("driverDialect"));
// metadata contributor to register the json type
properties.put("hibernate.metadata_builder_contributor", "org.keycloak.models.map.storage.jpa.hibernate.jsonb.JsonbMetadataBuilderContributor");
properties.put("jakarta.persistence.validation.mode", ValidationMode.NONE.name());
Long lockTimeout = config.getLong("lockTimeout", DEFAULT_LOCK_TIMEOUT);
if (lockTimeout >= 0) {
// This property does not work for PostgreSQL/CockroachDB - https://hibernate.atlassian.net/browse/HHH-16181