当前位置:编程学习 > JAVA >>

hibernate已经写好了实体类和配置文件,怎么生成数据表

是随便写个方法就可以吗?但报这个错
Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.vo.bean.T1. Expected: class java.lang.Integer, got class com.vo.bean.T1

package com.vo.bean;

import java.io.Serializable;

public class T1 implements Serializable{

private Integer id;
private String name;
public T1() {
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}




<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.vo.bean.T1" table="t_t1" catalog="oracle1">
     <id name="id" type="java.lang.Integer">
     <column name="id"></column>
     <generator class="sequence">
     <param name="sequence">seq_t_t1</param>
     </generator>
     </id>
     <property name="name" type="java.lang.String">
     <column name="name"></column>
     </property>
    </class>
</hibernate-mapping>

以上是代码,请问该怎么办了 --------------------编程问答--------------------  Configuration conf=new Configuration();
 conf.configure("/hibernate.cfg.xml");
 SchemaExport dbExport=new SchemaExport(conf);
 dbExport.create(true, true); --------------------编程问答--------------------
引用 1 楼 shxt_xiaozhi 的回复:
 Configuration conf=new Configuration();
 conf.configure("/hibernate.cfg.xml");
 SchemaExport dbExport=new SchemaExport(conf);
 dbExport.create(true, true);


执行了,控制台显示建表语句了,但是数据库还是没有啊


--------------------编程问答--------------------
引用 1 楼 shxt_xiaozhi 的回复:
 Configuration conf=new Configuration();
 conf.configure("/hibernate.cfg.xml");
 SchemaExport dbExport=new SchemaExport(conf);
 dbExport.create(true, true);

图片在这,刚传错了 --------------------编程问答-------------------- 楼主链接的数据库名是oracle1吗 --------------------编程问答--------------------
引用 4 楼 shxt_xiaozhi 的回复:
楼主链接的数据库名是oracle1吗
是的啊 --------------------编程问答-------------------- 如果只用hibernate的话,用默认名的话
你看一下你两个配置文件名字写对了没. 
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,