hibernate mysql自动建表出错,原因是什么?
Employee.hbm.xml的代码是:<hibernate-mappingpackage="com.jwos.domain"><classname="Employee...
Employee.hbm.xml 的代码是:
<hibernate-mapping package="com.jwos.domain">
<class name="Employee" table="employee" >
<id name="id" column="id" type="java.lang.Integer" >
<generator class="increment"></generator></id>
<property name="name" type="java.lang.String">
<column name="name" not-null="false" />
</property>
<property name="email" type="java.lang.String">
<column name="email" not-null="false" />
</property>
<property name="hiredate" type="java.util.Date">
<column name="hiredate" />
</property>
</class>
</hibernate-mapping>
hibernate.cfg.xml代码是:
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">3131624</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2dd1.auto">create</property>
<property name="show_sql">true</property>
<!-- 指定要管理的对象文件 -->
<mapping resource="com/jwos/domain/Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
报错是Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator 展开
<hibernate-mapping package="com.jwos.domain">
<class name="Employee" table="employee" >
<id name="id" column="id" type="java.lang.Integer" >
<generator class="increment"></generator></id>
<property name="name" type="java.lang.String">
<column name="name" not-null="false" />
</property>
<property name="email" type="java.lang.String">
<column name="email" not-null="false" />
</property>
<property name="hiredate" type="java.util.Date">
<column name="hiredate" />
</property>
</class>
</hibernate-mapping>
hibernate.cfg.xml代码是:
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">3131624</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2dd1.auto">create</property>
<property name="show_sql">true</property>
<!-- 指定要管理的对象文件 -->
<mapping resource="com/jwos/domain/Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
报错是Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |