现在配置文件均已写好 确认无误
package com.hibernate.model;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;@Entity
@Table(name="_Teacher")
public class Teacher {
private int id;
private String name;
private String wife;
private Date time;
private Ok ok;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getWife() {
return wife;
}
public void setWife(String wife) {
this.wife = wife;
}
@Temporal(TemporalType.TIME)
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
@Enumerated(EnumType.STRING)
public Ok getOk() {
return ok;
}
public void setOk(Ok ok) {
this.ok = ok;
}
}以上是配置问题但是现在用junit4 缺显示如下异常,请各位帮忙看一下 具体是那出错了
00:41:43,688 INFO SchemaExport:226 - Running hbm2ddl schema export
00:41:43,691 DEBUG SchemaExport:242 - import file not found: /import.sql
00:41:43,691 INFO SchemaExport:251 - exporting generated schema to database
00:41:43,696 DEBUG SchemaExport:377 -
drop table if exists _Teacher
00:41:43,699 DEBUG SchemaExport:362 - Unsuccessful: drop table if exists _Teacher
00:41:43,700 DEBUG SchemaExport:363 - 关键字 'if' 附近有语法错误。
00:41:43,700 DEBUG SchemaExport:377 -
create table _Teacher (
id integer not null auto_increment,
name varchar(255),
ok varchar(255),
time time,
wife varchar(255),
primary key (id)
)
00:41:43,701 ERROR SchemaExport:348 - Unsuccessful: create table _Teacher (id integer not null auto_increment, name varchar(255), ok varchar(255), time time, wife varchar(255), primary key (id))
00:41:43,701 ERROR SchemaExport:349 - 'auto_increment' 附近有语法错误。
00:41:43,701 INFO SchemaExport:268 - schema export complete
Hibernate:
insert
into
_Teacher
(name, ok, time, wife)
values
(?, ?, ?, ?)
00:41:43,785 WARN JDBCExceptionReporter:100 - SQL Error: 208, SQLState: S0002
00:41:43,787 ERROR JDBCExceptionReporter:101 - 对象名 '_Teacher' 无效。
package com.hibernate.model;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;@Entity
@Table(name="_Teacher")
public class Teacher {
private int id;
private String name;
private String wife;
private Date time;
private Ok ok;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getWife() {
return wife;
}
public void setWife(String wife) {
this.wife = wife;
}
@Temporal(TemporalType.TIME)
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
@Enumerated(EnumType.STRING)
public Ok getOk() {
return ok;
}
public void setOk(Ok ok) {
this.ok = ok;
}
}以上是配置问题但是现在用junit4 缺显示如下异常,请各位帮忙看一下 具体是那出错了
00:41:43,688 INFO SchemaExport:226 - Running hbm2ddl schema export
00:41:43,691 DEBUG SchemaExport:242 - import file not found: /import.sql
00:41:43,691 INFO SchemaExport:251 - exporting generated schema to database
00:41:43,696 DEBUG SchemaExport:377 -
drop table if exists _Teacher
00:41:43,699 DEBUG SchemaExport:362 - Unsuccessful: drop table if exists _Teacher
00:41:43,700 DEBUG SchemaExport:363 - 关键字 'if' 附近有语法错误。
00:41:43,700 DEBUG SchemaExport:377 -
create table _Teacher (
id integer not null auto_increment,
name varchar(255),
ok varchar(255),
time time,
wife varchar(255),
primary key (id)
)
00:41:43,701 ERROR SchemaExport:348 - Unsuccessful: create table _Teacher (id integer not null auto_increment, name varchar(255), ok varchar(255), time time, wife varchar(255), primary key (id))
00:41:43,701 ERROR SchemaExport:349 - 'auto_increment' 附近有语法错误。
00:41:43,701 INFO SchemaExport:268 - schema export complete
Hibernate:
insert
into
_Teacher
(name, ok, time, wife)
values
(?, ?, ?, ?)
00:41:43,785 WARN JDBCExceptionReporter:100 - SQL Error: 208, SQLState: S0002
00:41:43,787 ERROR JDBCExceptionReporter:101 - 对象名 '_Teacher' 无效。
解决方案 »
- 请教lucene3.5 过滤器Filter的用法
- Bad version number in .class file
- 求助:如何移除已持久化的EJB定时事务?
- applet小程序技术在B/S程序中很重要吗?
- 一个j2ee项目,找文件路径时发生异常
- 关于系统启动时多线程问题,高手进来看看呀!
- 关于EJB客户端调用远程服务器的问题
- corba和ejb急救
- 高手请进:一个关于EJB问题(在线等待)
- Eclipse安装配置Tomcat后,未出现tomcat的三个小图标;新建Dynamic web项目用来运行servers--TomcatTest测试出错!
- 关于J2EE开发中分层架构的设计
- lucene 重建索引时 内存溢出问题
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId()
{
return id;
}Hibernate注解三个常见问题
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
配置成:
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>仔细检查下你的SQL语言。