Example usage for javax.persistence EntityManagerFactory getProperties

List of usage examples for javax.persistence EntityManagerFactory getProperties

Introduction

In this page you can find the example usage for javax.persistence EntityManagerFactory getProperties.

Prototype

public Map<String, Object> getProperties();

Source Link

Document

Get the properties and associated values that are in effect for the entity manager factory.

Usage

From source file:org.seedstack.spring.internal.SpringEntityManagerLink.java

private String getUnitName(EntityManagerFactory emf) {
    Map<String, Object> properties = emf.getProperties();

    String unitName = String.valueOf(properties.get(HIBERNATE_UNIT_NAME_PROPERTY));
    if (StringUtils.isBlank(unitName)) {
        unitName = String.valueOf(properties.get(GENERIC_UNIT_NAME_PROPERTY));
    } else if (StringUtils.isBlank(unitName)) {
        throw SeedException.createNew(SpringErrorCode.UNABLE_TO_RESOLVE_JPA_UNIT).put("entityManagerFactory",
                emf.toString());/*from ww w  . j a va  2 s. c  o  m*/
    }

    return unitName;
}

From source file:org.eclipse.jubula.client.core.persistence.Persistor.java

/**
 * /*from   w w  w .j  a  v a2 s  . c  om*/
 * @param factory The factory from which to retrieve the property.
 * @param key The key/name of the property to retrieve.
 * @return the string value of the retrieved property. Returns 
 *         <code>null</code> if the factory does not contain the desired 
 *         property or if the value of the property is <code>null</code>
 *         or if the string representation of the property value is
 *         <code>null</code>.
 */
private static String getFactoryProperty(EntityManagerFactory factory, String key) {

    if (factory != null && factory.isOpen()) {
        return ObjectUtils.toString(factory.getProperties().get(key));
    }

    return null;
}

From source file:utilities.PopulateDatabase.java

private static String findProperty(EntityManagerFactory entityManagerfactory, String property) {
    String result;//w  w w . j av  a2 s .co  m
    Map<String, Object> properties;
    Object value;

    properties = entityManagerfactory.getProperties();
    // for (Entry<String, Object> entry : properties.entrySet())
    //   System.out.println(String.format("%s = %s", entry.getKey(), entry.getValue()));      
    value = properties.get(property);
    if (value == null)
        throw new RuntimeException(String.format("Property `%s' not found", property));
    if (!(value instanceof String))
        throw new RuntimeException(String.format("Property `%s' is not a string", property));
    result = (String) value;
    if (StringUtils.isBlank(result))
        throw new RuntimeException(String.format("Property `%s' is blank", property));

    return result;
}