spring—使用基于HibernateXML的配置时,我们可以查看h2控制台吗?

vwhgwdsa  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(396)

我必须坚持下一节课

public class Hotel {
    @Id
    private String hotelName;
    private String RoomType;
    private String status;
    private int Price;
    private int gst;

我的hibernate.cfg.xml文件是

<hibernate-configuration>
    <session-factory>
        <!-- JDBC Database connection settings -->
        <property name="connection.driver_class">org.h2.Driver</property>
        <property name="connection.url">jdbc:h2:mem:test</property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>
        <!-- JDBC connection pool settings ... using built-in test pool -->
        <property name="connection.pool_size">1</property>
        <!-- Select our SQL dialect -->
        <property name="dialect">org.hibernate.dialect.H2Dialect</property>
        <!-- Echo the SQL to stdout -->
        <property name="show_sql">true</property>
        <!-- Set the current session context -->
        <property name="current_session_context_class">thread</property>
        <property name="hbm2ddl.auto">create-drop</property>
        <mapping class="com.wipro.BED1.Hotel" />

    </session-factory>

我的控制台显示了这一点,但是我知道如何使用h2控制台来查看表,因为我想查看常规表。

INFO: HHH10001003: Autocommit mode: false
Apr 14, 2021 11:38:41 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Apr 14, 2021 11:38:42 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table if exists hotels CASCADE 
Apr 14, 2021 11:38:43 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@1a4d1ab7] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table hotels (hotelName varchar(255) not null, Price integer not null, RoomType varchar(255), gst integer not null, status varchar(255), primary key (hotelName))
Apr 14, 2021 11:38:43 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@761e788f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: insert into hotels (Price, RoomType, gst, status, hotelName) values (?, ?, ?, ?, ?)
utugiqy6

utugiqy61#

有一个属性你设置为真
spring.h2.console.enabled=真
试试看,应该有用

相关问题