Moved hbm.xml -> annotations.

This commit is contained in:
Svyatoslav Reyentenko 2010-12-06 23:44:14 +03:00 committed by adamw
parent c2ba8360c8
commit 76b59a702c
4 changed files with 13 additions and 26 deletions

View File

@ -24,8 +24,8 @@ public class CollectionChangeNoRevisionTest extends AbstractSessionTest {
@Override @Override
protected void initMappings() throws MappingException, URISyntaxException { protected void initMappings() throws MappingException, URISyntaxException {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/norevision/mappings.hbm.xml"); config.addAnnotatedClass(Person.class);
config.addFile(new File(url.toURI())); config.addAnnotatedClass(Name.class);
config.setProperty("org.hibernate.envers.revision_on_collection_change", getCollectionChangeValue()); config.setProperty("org.hibernate.envers.revision_on_collection_change", getCollectionChangeValue());
} }

View File

@ -2,15 +2,19 @@ package org.hibernate.envers.test.integration.collection.norevision;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@Audited @Audited
@Entity
public class Name implements Serializable { public class Name implements Serializable {
@Id
@GeneratedValue
private Integer id; private Integer id;
private String name; private String name;
@ManyToOne
@JoinColumn(name = "person_id", insertable = false, updatable = false)
private Person person; private Person person;
public Integer getId() { public Integer getId() {

View File

@ -3,15 +3,19 @@ package org.hibernate.envers.test.integration.collection.norevision;
import org.hibernate.envers.AuditMappedBy; import org.hibernate.envers.AuditMappedBy;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@Audited @Audited
@Entity
public class Person implements Serializable { public class Person implements Serializable {
@Id @GeneratedValue
private Integer id; private Integer id;
@AuditMappedBy(mappedBy = "person") @AuditMappedBy(mappedBy = "person")
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "person_id")
private Set<Name> names; private Set<Name> names;
public Person() { public Person() {

View File

@ -1,21 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.hibernate.envers.test.integration.collection.norevision.Person">
<id name="id">
<generator class="native"/>
</id>
<set name="names" cascade="save-update">
<key column="Person_Id"/>
<one-to-many class="org.hibernate.envers.test.integration.collection.norevision.Name"/>
</set>
</class>
<class name="org.hibernate.envers.test.integration.collection.norevision.Name">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<many-to-one name="person" class="org.hibernate.envers.test.integration.collection.norevision.Person"
column="Person_Id" cascade="save-update" update="false" insert="false"/>
</class>
</hibernate-mapping>