private void dumpConfiguration (final Ejb3Configuration config) { final Properties properties = config.getProperties(); for (final Object propertyName : new TreeSet<Object>(properties.keySet())) { logger.fine("JPA configuration: %s = %s", propertyName, properties.get(propertyName)); } }
/** * Gets the database dialect from the Hibernate <code>Ejb3Configuration</code. * * @param configuration The hibernate config, not null * @return the database Dialect, not null */ protected Dialect getHibernateDatabaseDialect(Ejb3Configuration configuration) { String dialectClassName = configuration.getProperties().getProperty("hibernate.dialect"); if (isEmpty(dialectClassName)) { throw new UnitilsException("Property hibernate.dialect not specified"); } try { return (Dialect) Class.forName(dialectClassName).newInstance(); } catch (Exception e) { throw new UnitilsException("Could not instantiate dialect class " + dialectClassName, e); } }
setupConfiguration(properties); Properties props = cfg.getProperties(); if (props.get(Environment.URL) == null) {
/** bind the configuration to the JNDI */ public static void bind(Ejb3Configuration cfg) { String name = cfg.getHibernateConfiguration().getProperty( HibernatePersistence.CONFIGURATION_JNDI_NAME ); if ( name == null ) { log.debug( "No JNDI name configured for binding Ejb3Configuration" ); } else { log.info( "Ejb3Configuration name: {}", name ); try { Context ctx = org.hibernate.util.NamingHelper.getInitialContext( cfg.getProperties() ); org.hibernate.util.NamingHelper.bind( ctx, name, cfg ); log.info( "Bound Ejb3Configuration to JNDI name: {}", name ); ( (EventContext) ctx ).addNamingListener( name, EventContext.OBJECT_SCOPE, LISTENER ); } catch (InvalidNameException ine) { log.error( "Invalid JNDI name: " + name, ine ); } catch (NamingException ne) { log.warn( "Could not bind Ejb3Configuration to JNDI", ne ); } catch (ClassCastException cce) { log.warn( "InitialContext did not implement EventContext" ); } } }
Properties unitProperties = cfg.getProperties(); unitProperties.setProperty(HIBERNATE_LOOKUP, F3TransactionManagerLookup.class.getName()); unitProperties.putAll(overrides.getProperties());
public static void bind(Ejb3Configuration cfg) { String name = cfg.getHibernateConfiguration().getProperty( AvailableSettings.CONFIGURATION_JNDI_NAME ); if ( name == null ) { LOG.debug( "No JNDI name configured for binding Ejb3Configuration" ); } else { LOG.ejb3ConfigurationName( name ); // todo : instantiating the JndiService here is temporary until HHH-6159 is resolved. JndiServiceImpl jndiService = new JndiServiceImpl( cfg.getProperties() ); try { jndiService.bind( name, cfg ); LOG.boundEjb3ConfigurationToJndiName( name ); try { jndiService.addListener( name, LISTENER ); } catch (Exception e) { LOG.couldNotBindJndiListener(); } } catch (JndiNameException e) { LOG.invalidJndiName( name, e ); } catch (JndiException e) { LOG.unableToBindEjb3ConfigurationToJndi( e ); } } }