我正在尝试将Hibernate envers添加到我的应用程序中。我使用的数据库已经有很多数据了。这是Hibernate配置
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">true</prop>
<prop key="hibernate.dialect">$conf{hibernate.dialect}</prop>
<prop key="hibernate.show_sql">$conf{hibernate.show_sql}</prop>
<prop key="hibernate.search.default.indexBase">$conf{hibernate.search.default.indexBase}</prop>
<prop key="hibernate.search.default.exclusive_index_use">false</prop>
</props>
</property>
这里是我要审核的实体(简化版)
@Entity
@Audited
@Table(name = "C_CONTACT", catalog = "dbo")
public class ContactTO {
private String firstName;
}
当我启动雄猫服务器时,出现此错误
2017-02-09 15:10:14,908 [localhost-startStop-1] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:146) - Database 'dbo' does not exist. Make sure that the name is entered correctly.
2017-02-09 15:10:14,908 [localhost-startStop-1] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:272) - HHH000299: Could not complete schema update
java.lang.NullPointerException
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:158)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScriptList(Configuration.java:1204)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:237)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:203)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5099)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5615)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我调试了,在第1204行Configuration.class(包org.hibernate.cfg)中,我看到应用程序试图创建REVINFO表。在那之前,table leCatalo为空,但在创建REVINFO后,它变成了“dbo”。
我还尝试将属性设置为“创建”,但在这种情况下,在创建AUDIT表期间会删除许多数据。阅读留档,我明白我可以使用“更新”。
-有什么想法或者解释吗?-谢谢
这是因为您的实体将catalog
属性指定为dbo
。在支持目录的数据库上,这通常是应该在其中创建/管理对象的数据库名称。
在SQL服务器上,dbo
通常意味着模式,因此您可能希望指定模式="dbo"
并删除@table
注释的曲库="dbo"
部分,或者让您正在连接的数据库用户只使用它配置为使用的任何默认值,这通常是dbo模式并将注释指定为@table(name="C_CONTACT")
。
要执行道德黑客攻击,我们需要一个测试模拟环境,为了方便我们下载并安装Kali Linux操作系统,可以在Virtual Box中下载Kali Linux OS。以下是下载Virtual Box和Kali Linux的基本步骤。 第1步:下载Virtual Box 在第1步中,我们下载Virtual Box,因为Virtual Box可以在当前操作系统中创建虚拟机。Virtual Box就像一个完全
问题内容: 我尝试通过bash脚本执行此命令,但出现以下错误: 错误stacktrace: {“错误”:“ IndexPrimaryShardNotAllocatedException [[my_index]主要未分配后api]”,“状态”:409} {“错误”:“ ElasticSearchIllegalArgumentException [无法更新非动态设置[[index.analysis.f
主要内容:第1步:下载依赖项JAR文件,第2步:创建项目并设置构建路径,SLF4J绑定,SLF4J的Pom.xml在本章中,我们将演示如何在Eclipse IDE中设置SLF4J环境。在继续安装之前,请确保已在系统中安装了Eclipse。如果还没有安装好,请下载并安装Eclipse。 如果对Eclipse不是很熟悉,请参阅Eclipse教程。 第1步:下载依赖项JAR文件 打开SLF4J网站的官方主页,进入下载页面。如下所示: 现在,根据您的操作系统(如果是windows则下载文件,Linux则
主要内容:安装数据库驱动,设置数据库凭据,下载Commons DBUtils存档要开始使用DBUtils进行开发,应该按照以下步骤设置DBUtils环境。 我们假设您正在开发Windows平台。 安装Java开发环境 安装MySQL或其它数据库 下载相关数据库驱动程序 安装数据库驱动 最新的JDK包含一个JDBC-ODBC Bridge驱动程序,它使大多数开放式数据库连接(ODBC)驱动程序可供使用JDBC API的程序员使用。 现在,大多数数据库供应商都在提供适当的JDBC
开发环境是您可以开发、测试、运行 Servlet 的地方。 就像任何其他的 Java 程序,您需要通过使用 Java 编译器 javac 编译 Servlet,在编译 Servlet 应用程序后,将它部署在配置的环境中以便测试和运行。 如果你使用的是 Eclipse 环境,可以直接参阅:Eclipse JSP/Servlet 环境搭建。 这个开发环境设置包括以下步骤: 设置 Java 开发工具包(
本地环境设置 如果您想要设置 C++ 语言环境,您需要确保电脑上有以下两款可用的软件,文本编辑器和 C++ 编译器。 文本编辑器 这将用于输入您的程序。文本编辑器包括 Windows Notepad、OS Edit command、Brief、Epsilon、EMACS 和 vim/vi。 文本编辑器的名称和版本在不同的操作系统上可能会有所不同。例如,Notepad 通常用于 Windows 操作