1 package ru.indvdum.jpa.dao
4 * @author indvdum (gotoindvdum[at]gmail[dot]com)
5 * @since 03.11.2011 13:53:32
8 class JPAPropertySelector {
9 public static final String SHOWSQL = "custom.showsql"
10 public static final String SYNCHRONIZEDB = "custom.synchronize"
11 public static final String SCHEMANAME = "custom.schemaname"
12 public static final String DBDICTIONARY = "custom.dbdictionary"
13 public static final String RUNTIMEENHANCEMENT = "custom.runtimeenhancement"
15 private static Properties properties = new Properties()
17 private static boolean isProperty(String propertyName) {
18 return Boolean.valueOf(properties.getProperty(propertyName)).booleanValue()
21 private static String getSystemProperty(String propertyName) {
22 properties.getProperty(propertyName)
25 static void setSystemProperty(String propertyName, String propertyValue) {
26 properties.setProperty(propertyName, propertyValue)
30 Map<String, String> emfProperties = [:]
32 if(isProperty(SHOWSQL)) {
33 emfProperties["openjpa.Log"] = "DefaultLevel=INFO, Tool=INFO, SQL=TRACE"
34 emfProperties["openjpa.ConnectionFactoryProperties"] = "PrintParameters=true, PrettyPrint=true"
37 if(isProperty(SYNCHRONIZEDB)) {
38 emfProperties["openjpa.jdbc.SynchronizeMappings"] = "buildSchema(ForeignKeys=true)"
41 if(getSystemProperty(SCHEMANAME) != null) {
42 emfProperties["openjpa.jdbc.Schema"] = getSystemProperty(SCHEMANAME)
45 if(getSystemProperty(DBDICTIONARY)) {
46 emfProperties["openjpa.jdbc.DBDictionary"] = getSystemProperty(DBDICTIONARY)
49 if(getSystemProperty(RUNTIMEENHANCEMENT)) {
50 emfProperties["openjpa.RuntimeUnenhancedClasses"] = getSystemProperty(RUNTIMEENHANCEMENT)