【发布时间】:2017-12-06 09:41:17
【问题描述】:
我在 h2 数据库控制台中看不到我作为模型类创建的表。
实际上我可以访问 h2 数据库(通过编写 localhost:/h2-console)。但我看不到我的桌子。
虽然我添加了@Entity 注解,但我在 h2-database 中看不到表。
产品型号类:
package com.example;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.math.BigDecimal;
/**
* Created by jt on 11/6/15.
*/
@Entity
public class Product implements DomainObject{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String description;
private BigDecimal price;
private String imageUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
}
【问题讨论】:
-
所有大写字母都被视为尖叫。避免这样做。
-
您是否让您的 JPA 提供商创建该表?您是否查看了您选择的 JPA 提供商的日志?有没有调试过?!
-
我使用了Intellij Idea,调试成功。当我在网络浏览器上写 localhost:8181/u2-console 时,我看到了 h2 数据库的登录屏幕。我连接了数据库,但我没有 PRODUCT 表。我还向 pom.xml 添加了 h2 依赖项。
-
不回答问题。您是否配置了您的 JPA 提供程序(无论您使用的是哪个......您还没有说)来生成表格?上述 JPA 提供者的 LOG 告诉您有关表生成的哪些内容? H2 不是 JPA 提供者。
-
我休眠了。