我正在通过另一个实用程序手动创建架构并且成功。
我正在使用config xml在其他地方创建会话工厂。
当我尝试运行Schema导出时,它会在日志中出现奇怪的错误,例如
13:18:33,932 ERROR SchemaExport:386 - Unsuccessful: create table entitydef (id bigint not null auto_increment unique, hbmfile LONGTEXT, isExported tinyint not null, name varchar(50), schemaId bigint, typeId bigint, primary key (id)) type=InnoDB
我尝试在sql workbench上运行查询,当我删除type = InnoDB部分时它会起作用。
这里有什么问题?为简洁起见,我删除了其余的pojo定义。
我创建了一个包含以下
的hibernate.cfg.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">**********</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dev_org_appops_entitystore_0_0_1</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="javax.persistence.validation.mode">none</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="default_entity_mode">POJO</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<!-- this is c3p0 configuration -->
<property name="org.hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.connection.autoReconnect">true</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.max_size">50</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.timeout">5</property>
<!--ehcache configuration-->
<mapping class="org.appops.entityStore.hibernate.dao.domain.Entitydef"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.Property"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.Propertydef"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.Schemadef"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.Types"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.QueryDef"/>
<mapping class="org.appops.entityStore.hibernate.dao.domain.QueryParamType"/>
</session-factory>
</hibernate-configuration>
我在下面注明了pojo
@Entity
@Table(name = "entitydef")
public class Entitydef implements java.io.Serializable {
private Long id;
private String name;
private Long typeId;
private Long schemaId;
private String hbmfile;
private byte isExported;
public Entitydef() {
}
public Entitydef(final byte isExported) {
this.isExported = isExported;
}
public Entitydef(final String name, final Long typeId, final Long schemaId, final String hbmfile,
final byte isExported) {
this.name = name;
this.typeId = typeId;
this.schemaId = schemaId;
this.hbmfile = hbmfile;
this.isExported = isExported;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
return this.id;
}
public void setId(final Long id) {
this.id = id;
}
@Column(name = "name", length = 50)
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
@Column(name = "typeId")
public Long getTypeId() {
return this.typeId;
}
public void setTypeId(final Long typeId) {
this.typeId = typeId;
}
@Column(name = "schemaId")
public Long getSchemaId() {
return this.schemaId;
}
public void setSchemaId(final Long schemaId) {
this.schemaId = schemaId;
}
@Column(name = "hbmfile", columnDefinition = "LONGTEXT")
public String getHbmfile() {
return this.hbmfile;
}
public void setHbmfile(final String hbmfile) {
this.hbmfile = hbmfile;
}
@Column(name = "isExported", nullable = false)
public byte getIsExported() {
return this.isExported;
}
public void setIsExported(final byte isExported) {
this.isExported = isExported;
}
}
答案 0 :(得分:1)
发现问题。
我需要使用
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
而不是
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
因为使用的MySql高于5.0