From fa5adc1979859352c407dbfd549f15e40628e9cd Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 19 May 2023 21:43:20 +0200 Subject: [PATCH] fix erroneous code example --- .../asciidoc/introduction/Configuration.adoc | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/documentation/src/main/asciidoc/introduction/Configuration.adoc b/documentation/src/main/asciidoc/introduction/Configuration.adoc index 78e24cf8a8..d1a3a48f62 100644 --- a/documentation/src/main/asciidoc/introduction/Configuration.adoc +++ b/documentation/src/main/asciidoc/introduction/Configuration.adoc @@ -209,17 +209,24 @@ Alternatively, the venerable class `org.hibernate.cfg.Configuration` allows an i [source,java] ---- -SessionFactory sessionFactory = new Configuration() - .addAnnotatedClass(Book.class) - .addAnnotatedClass(Author.class) - .setProperty(AvailableSettings.JAKARTA_JDBC_URL, "jdbc:postgresql://localhost/example") - .setProperty(AvailableSettings.JAKARTA_JDBC_USER, user) - .setProperty(AvailableSettings.JAKARTA_JDBC_PASSWORD, password) - .setProperty(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE) - .setProperty(AvailableSettings.SHOW_SQL, true) - .setProperty(AvailableSettings.FORMAT_SQL, true) - .setProperty(AvailableSettings.HIGHLIGHT_SQL, true) - .buildSessionFactory(); +SessionFactory sessionFactory = + new Configuration() + .addAnnotatedClass(Book.class) + .addAnnotatedClass(Author.class) + // PostgreSQL + .setProperty(AvailableSettings.JAKARTA_JDBC_URL, "jdbc:postgresql://localhost/example") + // Credentials + .setProperty(AvailableSettings.JAKARTA_JDBC_USER, user) + .setProperty(AvailableSettings.JAKARTA_JDBC_PASSWORD, password) + // Automatic schema export + .setProperty(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, + Action.CREATE.getExternalJpaName()) + // SQL statement logging + .setProperty(AvailableSettings.SHOW_SQL, TRUE.toString()) + .setProperty(AvailableSettings.FORMAT_SQL, TRUE.toString()) + .setProperty(AvailableSettings.HIGHLIGHT_SQL, TRUE.toString()) + // Create a new SessionFactory + .buildSessionFactory(); ---- The `Configuration` class has survived almost unchanged since the very earliest (pre-1.0) versions of Hibernate, and so it doesn't look particularly modern.