Skip to content

Commit fa5adc1

Browse files
committed
fix erroneous code example
1 parent f3ca2d6 commit fa5adc1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

documentation/src/main/asciidoc/introduction/Configuration.adoc

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,24 @@ Alternatively, the venerable class `org.hibernate.cfg.Configuration` allows an i
209209

210210
[source,java]
211211
----
212-
SessionFactory sessionFactory = new Configuration()
213-
.addAnnotatedClass(Book.class)
214-
.addAnnotatedClass(Author.class)
215-
.setProperty(AvailableSettings.JAKARTA_JDBC_URL, "jdbc:postgresql://localhost/example")
216-
.setProperty(AvailableSettings.JAKARTA_JDBC_USER, user)
217-
.setProperty(AvailableSettings.JAKARTA_JDBC_PASSWORD, password)
218-
.setProperty(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION, Action.CREATE)
219-
.setProperty(AvailableSettings.SHOW_SQL, true)
220-
.setProperty(AvailableSettings.FORMAT_SQL, true)
221-
.setProperty(AvailableSettings.HIGHLIGHT_SQL, true)
222-
.buildSessionFactory();
212+
SessionFactory sessionFactory =
213+
new Configuration()
214+
.addAnnotatedClass(Book.class)
215+
.addAnnotatedClass(Author.class)
216+
// PostgreSQL
217+
.setProperty(AvailableSettings.JAKARTA_JDBC_URL, "jdbc:postgresql://localhost/example")
218+
// Credentials
219+
.setProperty(AvailableSettings.JAKARTA_JDBC_USER, user)
220+
.setProperty(AvailableSettings.JAKARTA_JDBC_PASSWORD, password)
221+
// Automatic schema export
222+
.setProperty(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
223+
Action.CREATE.getExternalJpaName())
224+
// SQL statement logging
225+
.setProperty(AvailableSettings.SHOW_SQL, TRUE.toString())
226+
.setProperty(AvailableSettings.FORMAT_SQL, TRUE.toString())
227+
.setProperty(AvailableSettings.HIGHLIGHT_SQL, TRUE.toString())
228+
// Create a new SessionFactory
229+
.buildSessionFactory();
223230
----
224231

225232
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.

0 commit comments

Comments
 (0)