diff options
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 709d2f057..ea90d4d67 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -222,11 +222,13 @@ public class DataManager { } } String query = config.getString(queryName); - if (query == null && generateQueries) { - query = constructObjectQuery(action, clazz, extended); - config.setString(queryName, query); - } else { - Log.info("Query not provided: " + queryName); + if (query == null) { + if (generateQueries) { + query = constructObjectQuery(action, clazz, extended); + config.setString(queryName, query); + } else { + Log.info("Query not provided: " + queryName); + } } return query; @@ -242,11 +244,14 @@ public class DataManager { queryName = "database.unlink" + owner.getSimpleName() + property.getSimpleName(); } String query = config.getString(queryName); - if (query == null && generateQueries) { - query = constructPermissionQuery(action, owner, property.equals(User.class) ? ManagedUser.class : property); - config.setString(queryName, query); - } else { - Log.info("Query not provided: " + queryName); + if (query == null) { + if (generateQueries) { + query = constructPermissionQuery(action, owner, + property.equals(User.class) ? ManagedUser.class : property); + config.setString(queryName, query); + } else { + Log.info("Query not provided: " + queryName); + } } return query; @@ -261,7 +266,12 @@ public class DataManager { } private static String getObjectsTableName(Class<?> clazz) { - return Introspector.decapitalize(clazz.getSimpleName()) + "s"; + String result = Introspector.decapitalize(clazz.getSimpleName()); + // Add "s" ending if object name is not plural already + if (!result.endsWith("s")) { + result += "s"; + } + return result; } private void initDatabaseSchema() throws SQLException, LiquibaseException { |