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>
以上是代码,请问该怎么办了
6 个解决方案
#1
Configuration conf=new Configuration();
conf.configure("/hibernate.cfg.xml");
SchemaExport dbExport=new SchemaExport(conf);
dbExport.create(true, true);
conf.configure("/hibernate.cfg.xml");
SchemaExport dbExport=new SchemaExport(conf);
dbExport.create(true, true);
#2
执行了,控制台显示建表语句了,但是数据库还是没有啊
#3
图片在这,刚传错了
#4
楼主链接的数据库名是oracle1吗
#5
是的啊
#6
如果只用hibernate的话,用默认名的话
你看一下你两个配置文件名字写对了没.
你看一下你两个配置文件名字写对了没.
#1
Configuration conf=new Configuration();
conf.configure("/hibernate.cfg.xml");
SchemaExport dbExport=new SchemaExport(conf);
dbExport.create(true, true);
conf.configure("/hibernate.cfg.xml");
SchemaExport dbExport=new SchemaExport(conf);
dbExport.create(true, true);
#2
执行了,控制台显示建表语句了,但是数据库还是没有啊
#3
图片在这,刚传错了
#4
楼主链接的数据库名是oracle1吗
#5
是的啊
#6
如果只用hibernate的话,用默认名的话
你看一下你两个配置文件名字写对了没.
你看一下你两个配置文件名字写对了没.