Hibernate不会创建表并自动更改

用户名

尝试使用休眠创建表,但是已创建并删除了它。

Console:

Hibernate: `create table category (catid integer not null auto_increment, catdesc varchar(255), cattitle varchar(255), primary key (catid)) type=MyISAM`
Hibernate: create table category_product (Category_catid integer not null, p_pid integer not null) type=MyISAM
Hibernate: create table product (pid integer not null auto_increment, pDesc varchar(255), pDiscount integer not null, pName varchar(255), pPhoto varchar(255), pPrice integer not null, pQuantity integer not null, c_catid integer, primary key (pid)) type=MyISAM
Hibernate: create table user (id integer not null auto_increment, address varchar(255), mail varchar(255), name varchar(255), pass varchar(255), ph_no integer not null, primary key (id)) type=MyISAM
Hibernate: alter table category_product drop index UK_52hqb12vl2fe0l0d78hk2d88h
Hibernate: alter table category_product add constraint UK_52hqb12vl2fe0l0d78hk2d88h unique (p_pid)
Hibernate: `alter table category_product add constraint FKsqii9ofndgvr0cscbvb5e4uds foreign key (p_pid) references product (pid)`
Hibernate: alter table category_product add constraint FK29xlj9k6tq2niv1udd6a1msmd foreign key (Category_catid) references category (catid)
Hibernate: alter table product add constraint FKsw4ctbskvoom8us7igpgu6fqt foreign key (c_catid) references category (catid)

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-configuration>
    <session-factory>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/shoppingcart?useSSL=false</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.connection.password">root123</property>
            <property name="show_sql">true</property>      
            <property name="hbm2ddl.auto">update</property>
            <mapping class="com.sourav.model.User"/>     
            <mapping class="com.sourav.model.Product"/>
            <mapping class="com.sourav.model.Category"/> 
    </session-factory>
</hibernate-configuration>

型号类别:

import java.util.List;

import javax.persistence.*;

@Entity
@Table(name="category")
public class Category {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int catid;
    private String cattitle;
    private String catdesc;
    @OneToMany
    private List<Product> p;
    public int getCatid() {
        return catid;
    }
    public void setCatid(int catid) {
        this.catid = catid;
    }
    public String getCattitle() {
        return cattitle;
    }
    public void setCattitle(String cattitle) {
        this.cattitle = cattitle;
    }
    public String getCatdesc() {
        return catdesc;
    }
    public void setCatdesc(String catdesc) {
        this.catdesc = catdesc;
    }
    public List<Product> getP() {
        return p;
    }
    public void setP(List<Product> p) {
        this.p = p;
    }
    public Category(String cattitle, String catdesc, List<Product> p) {
        super();
        this.cattitle = cattitle;
        this.catdesc = catdesc;
        this.p = p;
    }
    
    
}

休眠:创建表类别(catid整数不为null,auto_increment,catdesc varchar(255),cattitle varchar(255),主键(catid))type = MyISAM休眠:创建表category_product(Category_catid整数不为null,p_pid整数不为null)类型= MyISAM Hibernate:创建表产品(pid整数不为null的auto_increment,pDesc varchar(255),pDiscount整数不为null,pName varchar(255),pPhoto varchar(255),pPrice整数不为null,pQuantity整数不为null,c_catid整数,主键(pid))type = MyISAM休眠:创建表用户(id整数不为null auto_increment,地址varchar(255),邮件varchar(255),名称varchar(255),传递varchar(255),ph_no整数不为null,主键(id))type = MyISAM休眠:更改表category_product删除索引UK_52hqb12vl2fe0l0d78hk2d88h休眠:更改表category_product添加约束UK_52hqb12vl2fe0l0d78hk2d88h唯一(p_pid)休眠:更改表category_product添加约束FKsqii9ofndgvr0cscbvb5e4uds外键(p_pid)引用product(pid)休眠:更改表category_product添加约束FK29xdj9n(1)产品添加约束FKsw4ctbskvoom8us7igpgu6fqt外键(c_catid)referenc更改表产品添加约束FKsw4ctbskvoom8us7igpgu6fqt外键(c_catid)referenc更改表产品添加约束FKsw4ctbskvoom8us7igpgu6fqt外键(c_catid)referenc

用户名

我已经通过删除解决了

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Hibernate没有在Spring应用程序中自动创建表

Hibernate没有在Spring应用程序中自动创建表

是否可以分离Hibernate实体,以使对对象的更改不会自动保存到数据库?

dbup不会自动创建schemaversions表

Hibernate在创建表之前尝试更改表

Hibernate是否自动在数据库中创建表

Hibernate不会自动创建表

Hibernate不会创建我的表

Hibernate不会自动创建表

无法使用Spring和Hibernate集成自动创建表并插入记录

HIbernate不会创建另一个数据库中已经存在的表

与JPA一起使用时,如何让Hibernate在数据库中自动创建表?

使用Spring和Hibernate自动创建/更新表

Sails不会创建mysql表

更改数据库连接后,EF Code First项目不会创建AspNetUsers,AspNetRoles等表

休眠:不会自动创建SQL Server数据库中的所有表

更改为身份自动创建的表。C#MVC什么使用.Net Core或Just .Net

使用NestJS和TypeOrm,运行NestJS应用程序后不会自动创建表

当我的API更改时,用useState创建的React状态不会自动更新

Hibernate不会自动创建数据库中不存在的表

z / OS上的Hibernate和DB2-自动创建表

git pull不会自动合并我的更改

创建其他工作表引用的主列表,并在主表更改时自动更新

Hibernate 不自动生成表

Hibernate + JPA 不会自动在 oracle 中创建表

自动创建 OrmLite 表

Hibernate 不会自动创建 FK 关系和引用(使用 Spring Boot)

.net core 3.0 自动迁移不会自动创建/更新/数据表

Spring boot不会在Mysql上自动创建数据库表