由hbm.xml和pojo类生成数据库表失败(求大侠赐招)

一下是我写的一个类,该类通过读取configur.xml文件来生成相应的数据表结构,但是在运行的时候一切正常,后台无任何错误,但是Oracle中依旧无法成功的把表创建出来。

package com.shop.dao;

import java.io.File;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class HibernateSchemaExport{

    static Session session;

    static Configuration config = null;
    static Transaction tx = null;

    public static void main(String[] args){
        /** *//**
         * 根据映射文件创建数据库结构
         */
        try {
            config = new Configuration().configure(new File("src/hibernate.cfg.xml"));

            System.out.println("Creating tables...");
           
            SessionFactory sessionFactory = config.buildSessionFactory();
            session = sessionFactory.openSession();
            tx = session.beginTransaction();

            SchemaExport schemaExport = new SchemaExport(config);
            schemaExport.create(true, true);
            System.out.println("Table created....");
            tx.commit();

        } catch (HibernateException e){
            e.printStackTrace();
            try{
                tx.rollback();
            } catch (HibernateException e1){
                e1.printStackTrace();
            }
        } finally{
         session.close();
        }
    }

}

程序运行完以后,console台的------

 Creating tables...

drop table shop.dbo.customer cascade constraints

drop table shop.dbo.orderDetail cascade constraints

drop table shop.dbo.orders cascade constraints

drop table shop.dbo.shop cascade constraints

drop sequence hibernate_sequence

create table shop.dbo.customer (customerid number(10,0) not null, customername varchar2(20 char), primary key (customerid))

create table shop.dbo.orderDetail (orderDetailId number(10,0) not null, shopid number(10,0), orderNum number(10,0), primary key (orderDetailId))

create table shop.dbo.orders (orderid number(10,0) not null, customerid number(10,0), orderdate timestamp, ordertotal float, primary key (orderid))

create table shop.dbo.shop (shopid number(10,0) not null, shopname varchar2(20 char), shopprice float, primary key (shopid))

alter table shop.dbo.orderDetail add constraint FK46C5593FE1CF842F foreign key (shopid) references shop.dbo.shop

alter table shop.dbo.orders add constraint FKC3DF62E5A2CD9FFF foreign key (customerid) references shop.dbo.customer

create sequence hibernate_sequence

Table created.

 

我用的数据库是Oracle9i,为什么我的表没有创建成功。。。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值