Use the appropriate database dialect to add quotes to the schema name (#26964)
Closes #25961 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
parent
59710e654c
commit
c7b51fc7f0
1 changed files with 4 additions and 1 deletions
|
@ -18,6 +18,8 @@
|
|||
package org.keycloak.connections.jpa.util;
|
||||
|
||||
import jakarta.persistence.ValidationMode;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||
|
@ -51,7 +53,8 @@ public class JpaUtils {
|
|||
|
||||
public static String getTableNameForNativeQuery(String tableName, EntityManager em) {
|
||||
String schema = (String) em.getEntityManagerFactory().getProperties().get(HIBERNATE_DEFAULT_SCHEMA);
|
||||
return (schema==null) ? tableName : "\"" + schema + "\"." + tableName;
|
||||
final Dialect dialect = em.getEntityManagerFactory().unwrap(SessionFactoryImpl.class).getJdbcServices().getDialect();
|
||||
return (schema==null) ? tableName : dialect.openQuote() + schema + dialect.closeQuote() + "." + tableName;
|
||||
}
|
||||
|
||||
public static EntityManagerFactory createEntityManagerFactory(KeycloakSession session, String unitName, Map<String, Object> properties, boolean jta) {
|
||||
|
|
Loading…
Reference in a new issue