如何在H2数据库中看到模型类

时间:2017-12-06 09:41:18

标签: java jpa h2

我无法在h2数据库控制台中看到我创建的模型类。

实际上我可以访问h2数据库(通过编写localhost:/ h2-console)。但我看不到我的桌子。

Altough我添加了@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;
    }
}

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我为u2数据库更正了我的jdbc url。现在,我可以看到我通过java创建的表(模型类)。