@@ -299,25 +299,23 @@ package org.hibernate.example;
299299
300300import org.hibernate.cfg.Configuration;
301301
302- import static java.lang.Boolean.TRUE;
303302import static java.lang.System.out;
304- import static org.hibernate.cfg.AvailableSettings.*;
305303
306304public class Main {
305+
307306 public static void main(String[] args) {
308- var sessionFactory = new Configuration()
309- .addAnnotatedClass(Book.class)
310- // use H2 in-memory database
311- .setProperty(URL, "jdbc:h2:mem:db1")
312- .setProperty(USER, "sa")
313- .setProperty(PASS, "")
314- // use Agroal connection pool
315- .setProperty("hibernate.agroal.maxSize", "20")
316- // display SQL in console
317- .setProperty(SHOW_SQL, TRUE.toString())
318- .setProperty(FORMAT_SQL, TRUE.toString())
319- .setProperty(HIGHLIGHT_SQL, TRUE.toString())
320- .buildSessionFactory();
307+ var sessionFactory =
308+ new Configuration()
309+ .addAnnotatedClass(Book.class)
310+ // use H2 in-memory database
311+ .setJdbcUrl("jdbc:h2:mem:db1")
312+ .setCredentials("sa", "")
313+ // use Agroal connection pool
314+ .setProperty("hibernate.agroal.maxSize", "20")
315+ // display, format, highlight SQL in console
316+ .showSql(true, true, true)
317+ // create the factory
318+ .buildSessionFactory();
321319
322320 // export the inferred database schema
323321 sessionFactory.getSchemaManager().exportMappedObjects(true);
@@ -417,6 +415,7 @@ import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTIO
417415import static org.hibernate.tool.schema.Action.CREATE;
418416
419417public class Main {
418+
420419 public static void main(String[] args) {
421420 var factory = createEntityManagerFactory("example",
422421 // export the inferred database schema
@@ -460,6 +459,7 @@ public class Main {
460459 entityManager.close();
461460 }
462461 }
462+
463463}
464464----
465465
0 commit comments