0
Envers有问题。起初,这里有我的两个Hibernate类:Envers添加用户信息
child.java:
@Entity
@Audited
public class child {
@Id
private int id;
private String text;
@ManyToOne
@JoinColumn(name="child")
private testclass parent;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
public String getText() {return text;}
public void setText(String text) {this.text = text;}
public testclass getParent() {return parent;}
public void setParent(testclass parent) {this.parent = parent;}
}
testclass.java:
@Entity
@Audited
public class testclass {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_template")
@SequenceGenerator(name="seq_template", sequenceName="tester_seq")
private int id;
private String text;
@OneToMany(mappedBy="parent")
private Set<child> childs;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
public String getText() {return text;}
public void setText(String text) {this.text = text;}
public Set<child> getChilds() {return childs;}
public void setChilds(Set<child> childs) {this.childs = childs;}
}
两个类都做工精细和审计信息,如时间戳存储好。
我想现在用审计信息用户名来扩展信息。为此,我创建了这些配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="ch.triwdata.envers.extensions">
<class name="ExtendedRevisionEntity" table="revinfo">
<id name="id" type="int">
<column name="rev" not-null="true"/>
<generator class="native"/>
</id>
<property name="timestamp" type="long" column="timestamp" />
<property name="username" type="string" not-null="true"/>
</class>
</hibernate-mapping>
有当然也与休眠配置的配置文件,但我不认为这是很重要的位置。
有人可以看到我的失败,为什么用户信息不存储?
问候 比约恩
PS: 也许这XML缺什么?自从开始,我添加了它:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/postgres</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="connection.password">****</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create-drop</property>
<mapping class="testclass"/>
<mapping class="child"/>
</session-factory>
</hibernate-configuration>
你得到任何异常或东西,你可以张贴在这里? – Amogh
eclipse说: 错误:3:60必须声明元素类型“hibernate-mapping”。 错误:4:55必须声明元素类型“class”。 错误:5:34必须声明元素类型“id”。 错误:6:40必须声明元素类型“列”。 错误:7:31必须声明元素类型“generator”。 错误:9:69必须为元素类型“property”声明属性“type”。 错误:9:69必须为元素类型“属性”声明属性“列”。 错误:10:60必须为元素类型“property”声明属性“type”。 错误:10:60必须为元素类型“property”声明属性“not-null”。 –
好的,我已经修复了这个问题......但是表没有用用户名创建列。它运行时没有问题,但没有创建列用户名。 –