Java Hibernate envers未使用注释更新REVINFO中手动添加的列
我使用纯java与hibernate Envers一起休眠独立应用程序,以获取表列中所做更改的更新,我使用sql server作为我的数据库,我是Envers的新手 这是我的“CustomRevisionEntity.java” CustomRevisionListener.javaJava Hibernate envers未使用注释更新REVINFO中手动添加的列,java,sql-server,hibernate,Java,Sql Server,Hibernate,我使用纯java与hibernate Envers一起休眠独立应用程序,以获取表列中所做更改的更新,我使用sql server作为我的数据库,我是Envers的新手 这是我的“CustomRevisionEntity.java” CustomRevisionListener.java public class CustomRevisionListener implements RevisionListener { public void newRevision(Object revisionEn
public class CustomRevisionListener implements RevisionListener {
public void newRevision(Object revisionEntity) {
CustomRevisionEntity revision = (CustomRevisionEntity) revisionEntity ;
String userName = Hibernate_Connection.getloggedUser();
revision.setUsername(userName);
}
}
Hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;instance=SQLEXPRESS_2012;DatabaseName=ETS_V11_DEV;integratedSecurity=true</property> -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> -->
<property name="show_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class= "Domain_hibernate_SQLServer.Domain"/>
<mapping class= "Domain_hibernate_SQLServer.CustomRevisionEntity"/>
</session-factory>
</hibernate-configuration>
表中只有3列,1列是REV,即autoincrement,第2列是REVTSTMP,第3列是USERNAME,不使用USERNAME,
我缺少的是,如果您需要更多信息,请发表评论。我认为问题来自您的注释配置,因此可以发布您的hbm.xml文件和用于anotation配置的类。感谢您使用RPS。我在上面的代码中添加了“hibernate.cfg.xml”文件。尽管我使用的是注释,所以不需要创建“hbm.xml”文件。这个文件有什么问题吗修复了一个愚蠢的错误,我在cfg.xml DOCTYPE上遇到了一个问题
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;instance=SQLEXPRESS_2012;DatabaseName=ETS_V11_DEV;integratedSecurity=true</property> -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> -->
<property name="show_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class= "Domain_hibernate_SQLServer.Domain"/>
<mapping class= "Domain_hibernate_SQLServer.CustomRevisionEntity"/>
</session-factory>
</hibernate-configuration>
/* insert org.hibernate.envers.DefaultRevisionEntity
*/ insert
into
REVINFO
(REVTSTMP)
values
(?)