File tree Expand file tree Collapse file tree 4 files changed +32
-9
lines changed
Expand file tree Collapse file tree 4 files changed +32
-9
lines changed Original file line number Diff line number Diff line change 55import org .hibernate .SessionFactory ;
66import org .hibernate .boot .MetadataSources ;
77import org .hibernate .boot .registry .StandardServiceRegistryBuilder ;
8+ import org .slf4j .Logger ;
9+ import org .slf4j .LoggerFactory ;
810
911import java .util .List ;
1012
1416 */
1517public class Main {
1618
17- /* public static final String URL = "jdbc:postgresql://localhost:5432/postgres";
18- public static final String USER = "postgres";
19- public static final String PASSWORD = "postgres";*/
20-
19+ private static final Logger log = LoggerFactory .getLogger (Main .class );
2120
2221 public static void main (String [] args ) {
22+
23+ log .info ("Hello" );
2324 var serviceRegistry = new StandardServiceRegistryBuilder ()
2425 .configure ("hibernate.cfg.xml" ).build ();
2526 var metadata = new MetadataSources (serviceRegistry ).getMetadataBuilder ().build ();
27+
2628 SessionFactory sessionFactory = metadata .getSessionFactoryBuilder ().build ();
2729
2830 createRecord (User .builder ().name ("name" ).build (), sessionFactory );
2931
3032 var session = sessionFactory .openSession ();
31- List <City > list = session .createQuery ("from model.City" , City .class ).list ();
32- System .out .println (list );
33+ List <City > list = session .createQuery ("from core.model.City" , City .class ).list ();
3334 }
3435
3536 private static <T > T createRecord (T record , SessionFactory factory ) {
Original file line number Diff line number Diff line change 99 <property name =" hibernate.dialect" >org.hibernate.dialect.PostgreSQL94Dialect</property >
1010
1111 <!-- Database Connection Settings -->
12- <property name =" hibernate.connection.driver_class" >org.postgresql.Driver </property >
13- <property name =" hibernate.connection.url" >jdbc:postgresql://localhost:5432/postgres</property >
12+ <property name =" hibernate.connection.driver_class" >net.sf.log4jdbc.sql.jdbcapi.DriverSpy </property >
13+ <property name =" hibernate.connection.url" >jdbc:log4jdbc: postgresql://localhost:5432/postgres</property >
1414 <property name =" hibernate.connection.username" >postgres</property >
1515 <property name =" hibernate.connection.password" >postgres</property >
1616 <property name =" hibernate.hbm2ddl.auto" >update</property >
17- <property name =" show_sql" >true</property >
17+ <!-- < property name="show_sql">true</property> -- >
1818 <mapping class =" core.model.CityType" />
1919 <mapping class =" core.model.City" />
2020 <mapping class =" core.model.User" />
Original file line number Diff line number Diff line change 1+ log4jdbc.spylogdelegator.name =net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <configuration >
3+
4+ <appender name =" STDOUT" class =" ch.qos.logback.core.ConsoleAppender" >
5+ <!-- encoders are assigned the type
6+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
7+ <encoder >
8+ <pattern >%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern >
9+ </encoder >
10+ </appender >
11+
12+ <root level =" info" >
13+ <appender-ref ref =" STDOUT" />
14+ </root >
15+ <logger name =" log4jdbc.log4j2" level =" error" additivity =" false" >
16+ <appender-ref ref =" STDOUT" />
17+ </logger >
18+
19+ <logger name =" jdbc.audit" level =" error" />
20+
21+ </configuration >
You can’t perform that action at this time.
0 commit comments