由hbm.xml和pojo类生成数据库表失败(求大侠赐招)
来源:互联网 发布:p视频的软件 编辑:程序博客网 时间:2024/04/30 03:29
一下是我写的一个类,该类通过读取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,为什么我的表没有创建成功。。。
- 由hbm.xml和pojo类生成数据库表失败(求大侠赐招)
- Myeclipse 自动生成POJO 类 和 .hbm.xml 文件
- 使用Hibernate Tools从数据库表生成pojo和hbm
- Intellij IDEA 根据数据库自动生成pojo和hbm
- hibernate 的 使用 MyEclipse 工具生成 POJO 类和映射文件*.hbm.xml
- 使用myeclipse的反向工程生成hibernate映射文件(.hbm.xml)和pojo类
- 使用middlegen(由数据库表生成hbm文件)
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件截图版
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 使用Hibernate-tools中的hbm2java和hbm2ddl根据hbm文件自动生成pojo和数据库脚本
- 利用Hibernate Tool 连接数据库, 生成java和hbm.xml
- 自动生成MVC模式下的POJO类及hbm.xml文件
- hibernate.cfg.xml 和每张表对应的hbm文件 生成数据库表
- 通过Hibernate的hbm.xml文件生成数据库表
- DIV+CSS网页布局实用技巧笔记
- http://www.partow.net/programming/hashfunctions/
- 四个按键对常用数值调整代码
- UEFI Boot Flow 系列之 DXE Phase
- sqlserver 编辑、修改字段说明(备注) sp_addextendedproperty
- 由hbm.xml和pojo类生成数据库表失败(求大侠赐招)
- dll与lib之间的区别
- ununtu 如何安装源文件
- Android 数据存储之 SharedPreference
- PHP dirname() 函数
- linux 增加用户 改密码 增加sudo权限
- virtualBox 全局设定
- 零拷贝技术的研究与实现
- CRF测试语料中统计准确度(最后两列是正确label与预测label)