0

When I create the hibernate database, Hibernate recognizes all the tables except for one. So, when I try to save something in there, I get an exception because the object does not exist. The table which fails to create is ORDER. Here is the code:

@Entity
@Table(name = "ORDER")
public class Order implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "order_id")
    private double order_id;
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name = "INORDER", joinColumns = {@JoinColumn(name = "order_id")}, inverseJoinColumns = {
            @JoinColumn(name = "item_id")})
    private List<Item> items;
    @Column(name = "delivered")
    private boolean delivered;
    @Column(name = "current_date")
    private Date current_date;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private Client client;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "address_id")
    private Address address;
    @Column(name = "order_price")
    private float order_price;

    public Order() {

    }

    public Order(Client client, Address address, float order_price, List<Item> items) {
        this.client = client;
        this.address = address;
        this.order_price = order_price;
        this.items = items;
        current_date = new Date();
        delivered = false;
    }

    public double getOrder_id() {
        return order_id;
    }

    public List<Item> getItems() {
        return items;
    }

    public boolean isDelivered() {
        return delivered;
    }

    public void confirmDelivery() {
        delivered = true;
    }

    public Date getCurrent_date() {
        return current_date;
    }

    public Client getClient() {
        return client;
    }

    public Address getAddress() {
        return address;
    }


    public float getOrder_price() {
        return order_price;
    }
}

and the hibernate.cfg.xml file:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:hsql://localhost/onlineShop</property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>


        <!-- database pooling information -->
        <property name="connection_provider_class">org.hibernate.connection.C3P0ConnectionProvider
        </property>
        <property name="c3p0.minPoolSize">5</property>
        <property name="c3p0.timeout">1000</property>

        <!-- using container-managed JNDI
        <property name="hibernate.connection.datasource">
           java:comp/env/jdbc/LiveDataSource
        </property>   -->


        <property name="hibernate.connection.CharSet">utf8</property>
        <property name="hibernate.connection.characterEncoding">utf8</property>
        <property name="hibernate.connection.useUnicode">true</property>



        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <property name="hibernate.hbm2ddl.auto">update</property>

        <mapping class="model.Address"/>
        <mapping class="model.Admin"/>
        <mapping class="model.Order"/>
        <mapping class="model.Brand"/>
        <mapping class="model.Client"/>
        <mapping class="model.GenericItem"/>
        <mapping class="model.Item"/>
        <mapping class="model.User"/>

    </session-factory>
</hibernate-configuration>

Also, if it's helpful, the error:

jul 21, 2014 4:04:45 AM org.apache.catalina.core.AprLifecycleListener init WARN: HHH000022: c3p0 properties were encountered, but the org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider provider class was not found on the classpath; these properties are going to be ignored. jul 21, 2014 4:05:14 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure ERROR: HHH000388: Unsuccessful: create table ORDER (order_id double not null, current_date timestamp, delivered boolean, order_price float, address_id double, user_id double, primary key (order_id)) jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: palabra no esperado: ORDER jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: HHH000388: Unsuccessful: alter table INORDER add constraint FK9F407529258ABBD5 foreign key (order_id) references ORDER jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: palabra no esperado: ORDER jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: HHH000388: Unsuccessful: alter table ORDER add constraint FK47F8F2E1433E755 foreign key (address_id) references ADDRESS jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: usuario no tiene privilegios suficientes o objeto no encontrado: PUBLIC.ORDER jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: HHH000388: Unsuccessful: alter table ORDER add constraint FK47F8F2E858D485F foreign key (user_id) references CLIENT jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: usuario no tiene privilegios suficientes o objeto no encontrado: PUBLIC.ORDER jul 21, 2014 4:05:15 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute WARN: SQL Error: -5501, SQLState: 42501 jul 21, 2014 4:05:17 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: usuario no tiene privilegios suficientes o objeto no encontrado: ORDER

user3808750
  • 13
  • 2
  • 9

0 Answers0