现在配置文件均已写好 确认无误
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' 无效。

解决方案 »

  1.   

    不清楚楼主数据库是怎么配置的: @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      public Integer getId()
      {
        return id;
      }Hibernate注解三个常见问题 
      

  2.   

    41:43,691 DEBUG SchemaExport:242 - import file not found: /import.sql
      

  3.   

    我以前有过类似问题,仔细检查是我马虎了。
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    配置成:
    <property name="dialect">org.hibernate.dialect.HSQLDialect</property>仔细检查下你的SQL语言。
      

  4.   

          ok了。   我现在是这么更改的。  我把配置的create改成了  validate  然后提前在库里建表就通过了。实际开发也是这样。 那就这样吧。 国情啊~~