mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-16 20:15:46 -06:00
Use the appropriate database dialect to add quotes to the schema name
Closes #25961 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
committed by
Alexander Schwartz
parent
c7a20935e7
commit
907aadfbf4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user