經過一些實驗,我得到了工作表的生成與envers
我用這些參數 hibernate.hbm2ddl.auto =創造降出現
錯誤,因爲表存在,所以我覺得,這個參數hibernate.hbm2ddl。汽車=更新將解決這個問題
登錄:
5755 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: myappcompany.base.Company_AUD -> company_AUD
5782 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: org.hibernate.envers.DefaultRevisionEntity -> REVINFO
5915 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
6746 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
6784 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
6785 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
9004 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table company (ID bigint not null auto_increment, CREATED datetime, CREATED_BY varchar(255), MODIFIED datetime, MODIFIED_BY varchar(255), NAME varchar(255) not null, primary key (ID))
9004 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Table 'company' already exists
10227 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<!--
Data Source config
-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" p:driverClassName="${jdbc.driver}" p:url="${jdbc.url}"
p:username="${jdbc.username}" p:password="${jdbc.password}" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entity-manager-factory-ref="entityManagerFactory" />
<!--
JPA config
-->
<tx:annotation-driven />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistence-xml-location="${persistence.xml.location}"
p:data-source-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="true" p:generateDdl="true">
</bean>
</property>
<property name="jpaProperties">
<value>
hibernate.ejb.naming_strategy=org.hibernate.cfg.DefaultNamingStrategy
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
</value>
</property>
</bean>
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
</beans>
在幾天我會做出一個完整的例子
其中@#%@%#是org.hibernate.tool.ant.HibernateToolTask找到了嗎? – 2009-06-04 16:37:45