All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.guicedee.guicedpersistence.readers.hibernateproperties.HibernateDefaultConnectionBaseBuilder Maven / Gradle / Ivy

Go to download

A complete JPA 2.1 implementation for Standalone or EE Implementation. Enables Multiple Persistence units with full JTA Support using BTM. Perfect for Guice implementations, test suites, and Guice enabled Web Applications or EAR Projects. Requires JDK 8

There is a newer version: 62
Show newest version
package com.guicedee.guicedpersistence.readers.hibernateproperties;

import com.oracle.jaxb21.PersistenceUnit;

import java.util.Properties;

/**
 * Reads the default connection properties for hibernate and configures the connection accordingly
 */
public class HibernateDefaultConnectionBaseBuilder
		implements com.guicedee.guicedpersistence.services.IPropertiesConnectionInfoReader
{

	@Override
	public com.guicedee.guicedpersistence.db.ConnectionBaseInfo populateConnectionBaseInfo(PersistenceUnit unit, Properties filteredProperties, com.guicedee.guicedpersistence.db.ConnectionBaseInfo cbi)
	{
		for (String prop : filteredProperties.stringPropertyNames())
		{
			switch (prop)
			{
				case "hibernate.connection.url":
				{
					if (cbi.getUrl() == null)
					{
						cbi.setUrl(filteredProperties.getProperty(prop));
					}
					break;
				}
				case "hibernate.connection.user":
				{
					if (cbi.getUsername() == null)
					{
						cbi.setUsername(filteredProperties.getProperty(prop));
					}
					break;
				}
				case "hibernate.connection.driver_class":
				{
					if (cbi.getDriverClass() == null)
					{
						cbi.setDriverClass(filteredProperties.getProperty(prop));
					}
					break;
				}
				default:
				{
					break;
				}
			}
		}
		return cbi;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy