H2 控制台看不到 hibernate 创建的表
H2 Console can not see tables created by hibernate
我有一个使用 JPA 的 JEE 网络项目,应该 运行 在 JBoss EAP 6.1.0.GA(AS 7.2.0.Final-红帽-8)。我想用内存数据库 H2 测试项目。我部署了我的应用程序,我在控制台上看到以下内容:
13:55:18,587 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: create table seatforshow (id integer not null, isFree boolean not null, price decimal(19,2), rowNo tinyint not null, seatNo tinyint not null, filmShow_id integer not null, primary key (id))
13:55:18,588 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E8171BAB7DF foreign key (cinema_id) references cinema
13:55:18,591 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E81D7BB783F foreign key (film_id) references film
13:55:18,593 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seat add constraint FK35CE0571BAB7DF foreign key (cinema_id) references cinema
13:55:18,595 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seatforshow add constraint FK5B4E2DA141F8E4BF foreign key (filmShow_id) references filmshow
13:55:18,597 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: create sequence hibernate_sequence start with 1 increment by 1
13:55:18,598 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 87) HHH000230: Schema export complete
但是,我打开后
localhost:8080/h2-console/console/
我在那里没有看到我的桌子。我想我可能需要提供架构名称(或数据库名称),但我不确定。有人可以帮忙吗?
问题出在上面显示的连接 URL 中:
jdbc:h2:~测试
这与定义数据源的文件 standalone.xml 中的连接 URL 不匹配。
一旦两者匹配,正确的数据库(以及表)就会显示在控制台上。
13:55:18,587 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: create table seatforshow (id integer not null, isFree boolean not null, price decimal(19,2), rowNo tinyint not null, seatNo tinyint not null, filmShow_id integer not null, primary key (id))
13:55:18,588 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E8171BAB7DF foreign key (cinema_id) references cinema
13:55:18,591 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E81D7BB783F foreign key (film_id) references film
13:55:18,593 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seat add constraint FK35CE0571BAB7DF foreign key (cinema_id) references cinema
13:55:18,595 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seatforshow add constraint FK5B4E2DA141F8E4BF foreign key (filmShow_id) references filmshow
13:55:18,597 INFO [stdout] (ServerService Thread Pool -- 87) Hibernate: create sequence hibernate_sequence start with 1 increment by 1
13:55:18,598 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 87) HHH000230: Schema export complete
但是,我打开后
localhost:8080/h2-console/console/
我在那里没有看到我的桌子。我想我可能需要提供架构名称(或数据库名称),但我不确定。有人可以帮忙吗?
问题出在上面显示的连接 URL 中: jdbc:h2:~测试 这与定义数据源的文件 standalone.xml 中的连接 URL 不匹配。 一旦两者匹配,正确的数据库(以及表)就会显示在控制台上。