Hibernate Envers - REVINFO表不存在。

时间:2021-01-21 08:19:25

I'm using Hibernate 4.3.6, and I tried making use of the Envers functionality by adding the @Audited annotation to one of my @Entity classes. (The envers jar - hibernate-envers-4.3.6.Final.jar - is on my CLASSPATH.)

我使用Hibernate 4.3.6,我尝试使用Envers功能,将@Audited注释添加到我的@Entity类中。(envers jar - hibernate-envers-4.3.6.Final)。jar——在我的类路径上。

When I run my code, which works fine persisting without the @Audited annotation, I get an org.hibernate.exception.SQLGrammarException:

当我运行我的代码时,如果没有@Audited注释,它可以运行良好的持久化,我就会得到一个org.hibernate.exception。

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'dbname.REVINFO' doesn't exist

I don't see any documentation about having to create the REVINFO table, so I'd assume it would be created automatically, but that doesn't seem to be happening. Am I missing something?

我没有看到任何关于创建REVINFO表的文档,所以我假定它会自动创建,但这似乎并没有发生。我遗漏了什么东西?

(If I create it manually, as per the schema described here - http://thinkinginsoftware.blogspot.co.il/2011/03/auditing-entities-with-hibernate-jpa.html - then I get an exception that *_AUD doesn't exist. I guess I have the same question about all the *_AUD tables.)

(如果我手动创建它,按照这里所描述的模式——http://thinkinginsoftware.blogspot.co.il/2011/03/auditing- enti-with-hibernate -jpa。html -然后我得到一个例外,*_AUD不存在。我想我对所有的*_AUD表都有相同的问题。

Thanks, Reuven

谢谢,鲁文

2 个解决方案

#1


6  

Yes, see the below: chapter 7. You need the REV INFO table and an audit table per entity, by default named {entity name}_AUD although this is configurable. To have them generated automatically you would need to enable Hibernate schema generation.

是的,见下面:第7章。您需要REV信息表和每个实体的审计表,默认名称为{entity name}_AUD,尽管这是可配置的。要让它们自动生成,您需要启用Hibernate模式生成。

http://docs.jboss.org/envers/docs/

http://docs.jboss.org/envers/docs/

I normally run schema generation against a test database and then synch the changes over to application database using some DB tool.

我通常在测试数据库中运行模式生成,然后使用一些DB工具将更改同步到应用程序数据库。

See also here for details of an Ant task which you can use to generate the DDL:

有关Ant任务的详细信息,请参阅这里,您可以使用该任务生成DDL:

http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-generateschema

http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html envers-generateschema

#2


1  

Please re check you have added <prop key="hibernate.hbm2ddl.auto">update</prop>property in the spring configuration file.

请重新检查您是否添加了 更新 属性”。

I also had same issue and just resolved it by adding above property.

我也有同样的问题,只是通过添加上面的属性来解决它。

Thanks.

谢谢。

#1


6  

Yes, see the below: chapter 7. You need the REV INFO table and an audit table per entity, by default named {entity name}_AUD although this is configurable. To have them generated automatically you would need to enable Hibernate schema generation.

是的,见下面:第7章。您需要REV信息表和每个实体的审计表,默认名称为{entity name}_AUD,尽管这是可配置的。要让它们自动生成,您需要启用Hibernate模式生成。

http://docs.jboss.org/envers/docs/

http://docs.jboss.org/envers/docs/

I normally run schema generation against a test database and then synch the changes over to application database using some DB tool.

我通常在测试数据库中运行模式生成,然后使用一些DB工具将更改同步到应用程序数据库。

See also here for details of an Ant task which you can use to generate the DDL:

有关Ant任务的详细信息,请参阅这里,您可以使用该任务生成DDL:

http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-generateschema

http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html envers-generateschema

#2


1  

Please re check you have added <prop key="hibernate.hbm2ddl.auto">update</prop>property in the spring configuration file.

请重新检查您是否添加了 更新 属性”。

I also had same issue and just resolved it by adding above property.

我也有同样的问题,只是通过添加上面的属性来解决它。

Thanks.

谢谢。