branch develop updated (c2615b7 -> e58c6d9)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git from c2615b7 Fixes #3929 Merge branch 'feature/3929' into develop new a6c16fc Warn user if dialect declared seems wrong (H2 dialect for a PostgreSQL database) and throws Exception if configuration is missing dialect new 36ebbfa Fix french in README new e58c6d9 Deprecate guessHibernateDialect The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit e58c6d9e4077c0e8e49ccb9ac621c903c7cbd58e Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:37:39 2016 +0200 Deprecate guessHibernateDialect commit 36ebbfae32bd35b40a3818902e0eb6832fa3d853 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:36:59 2016 +0200 Fix french in README commit a6c16fcb9d9b57349015b0a66014801bce1c2521 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:33:26 2016 +0200 Warn user if dialect declared seems wrong (H2 dialect for a PostgreSQL database) and throws Exception if configuration is missing dialect Summary of changes: README.md | 2 +- .../persistence/internal/HibernateProvider.java | 42 +++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit a6c16fcb9d9b57349015b0a66014801bce1c2521 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:33:26 2016 +0200 Warn user if dialect declared seems wrong (H2 dialect for a PostgreSQL database) and throws Exception if configuration is missing dialect --- .../persistence/internal/HibernateProvider.java | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java index b82fd90..84eb26b 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java @@ -50,6 +50,7 @@ import org.hibernate.service.spi.Stoppable; import org.nuiton.topia.persistence.HibernateAvailableSettings; import org.nuiton.topia.persistence.TopiaConfiguration; import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.TopiaMisconfigurationException; import org.nuiton.topia.persistence.internal.support.TopiaHibernateEventListener; import org.nuiton.topia.persistence.jdbc.JdbcConfigurationBuilder; import org.nuiton.topia.persistence.support.TopiaServiceSupport; @@ -161,12 +162,41 @@ public class HibernateProvider { } + /** + * Get Hibernate {@link org.hibernate.dialect.Dialect} to use for given {@link TopiaConfiguration}. + * + * Prefer user defined dialect over dialect guessed by ToPIA; + * Warn user if dialect declared seems wrong (H2 dialect for a PostgreSQL database) + * @throws TopiaMisconfigurationException if user must add dialect to its configuration (because it can not be guessed) + */ public static String getHibernateDialect(TopiaConfiguration topiaConfiguration) { - String hibernateDialect = topiaConfiguration.getHibernateExtraConfiguration().get(AvailableSettings.DIALECT); - if (hibernateDialect == null) { - hibernateDialect = guessHibernateDialect(topiaConfiguration.getJdbcConnectionUrl()); + String jdbcConnectionUrl = topiaConfiguration.getJdbcConnectionUrl(); + String guessedDialect = guessHibernateDialect(jdbcConnectionUrl); + String userDefinedDialect = topiaConfiguration.getHibernateExtraConfiguration().get(AvailableSettings.DIALECT); + String dialect; + if (guessedDialect == null) { + if (userDefinedDialect == null) { + String message = String.format( + "unable to guess Hibernate dialect to use for JDBC URL %s please patch ToPIA or configure Hibernate manually using %s", + jdbcConnectionUrl, + HibernateAvailableSettings.DIALECT); + throw new TopiaMisconfigurationException(message, topiaConfiguration); + } else { + dialect = userDefinedDialect; + } + } else { + if (userDefinedDialect == null) { + dialect = guessedDialect; + } else { + dialect = userDefinedDialect; + if (guessedDialect.equals(userDefinedDialect)) { + log.info("configuration defined hibernate dialect " + userDefinedDialect + " but ToPIA could have guessed it (you can remove the configuration directive safely)"); + } else { + log.warn("not sure if " + dialect + " is suitable for " + jdbcConnectionUrl); + } + } } - return hibernateDialect; + return dialect; } public static String guessHibernateDialect(String jdbcConnectionUrl) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit 36ebbfae32bd35b40a3818902e0eb6832fa3d853 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:36:59 2016 +0200 Fix french in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cec75cd..9e20413 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To ensure extensibility, ToPIA itself and all the generated code is designed to You should not use ToPIA in the following case: -* Your persistence infrastructure is not a relational SGBD (you want NoSQL) +* Your persistence infrastructure is not an RDBMS (you want NoSQL) * Your model is dynamic: you don’t know exactly what are the data the end-user will store and you don’t want to be coerced to type everything everywhere * You’re happy with Hibernate 4 or plain old JDBC: ToPIA was made when JDO was the primary persistence solution in the Java world and ToPIA 2 was based on Hibernate 3. ToPIA 3 is based on Hibernate 4 and it’s clear that Java entities with annotations here and there works fine * The database already exists and the schema is already defined (by another application), you want your model to adapt to an existing schema, you can’t change the schema. ToPIA is a model-centric framework, not a database-centric one. Maybe you should use a database-centric framework like jOOQ. -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git commit e58c6d9e4077c0e8e49ccb9ac621c903c7cbd58e Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Apr 29 17:37:39 2016 +0200 Deprecate guessHibernateDialect --- .../java/org/nuiton/topia/persistence/internal/HibernateProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java index 84eb26b..b875769 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/persistence/internal/HibernateProvider.java @@ -199,6 +199,10 @@ public class HibernateProvider { return dialect; } + /** + * @deprecated Hibernate can do a much better job at guessing the dialect by calling JDBC and discovering the actual DBMS version and the dialect to use. + */ + @Deprecated public static String guessHibernateDialect(String jdbcConnectionUrl) { JdbcConfigurationBuilder jdbcConfigurationBuilder = new JdbcConfigurationBuilder(); String guessedHibernateDialect = null; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm