Class JpaUtils

    • Constructor Detail

      • JpaUtils

        public JpaUtils()
    • Method Detail

      • getTableNameForNativeQuery

        public static String getTableNameForNativeQuery​(String tableName,
                                                        javax.persistence.EntityManager em)
      • createEntityManagerFactory

        public static javax.persistence.EntityManagerFactory createEntityManagerFactory​(KeycloakSession session,
                                                                                        String unitName,
                                                                                        Map<String,​Object> properties,
                                                                                        boolean jta)
      • getProvidedEntities

        public static List<Class<?>> getProvidedEntities​(KeycloakSession session)
        Get a list of all provided entities by looping over all configured entity providers.
        session - the keycloak session
        a list of all provided entities (can be an empty list)
      • getCustomChangelogTableName

        public static String getCustomChangelogTableName​(String jpaEntityProviderFactoryId)
        Get the name of custom table for liquibase updates for give ID of JpaEntityProvider
        jpaEntityProviderFactoryId -
        table name
      • loadSqlProperties

        public static Properties loadSqlProperties​(URL url)
        Loads the URL as a properties file.
        url - The url to load, it can be null
        A properties file with the url loaded or null
      • loadSpecificNamedQueries

        public static Properties loadSpecificNamedQueries​(String databaseType)
        Method that adds the different query variants for the database. The method loads the queries specified in the files META-INF/queries-{dbType}.properties and the default META-INF/ At least the default file should exist inside the jar file. The default file contains all the needed queries and the specific one can overload all or some of them for that database type.
        em - The entity manager to use
        databaseType - The database type as managed in
      • configureNamedQuery

        public static void configureNamedQuery​(String queryName,
                                               String querySql,
                                               javax.persistence.EntityManager entityManager)
        Configures a named query to Hibernate.
        queryName - the query name
        querySql - the query SQL
        entityManager - the entity manager
      • getDatabaseType

        public static String getDatabaseType​(String productName)
      • closeEntityManager

        public static void closeEntityManager​(javax.persistence.EntityManager em)
        Helper to close the entity manager.
        em - The entity manager to close