Hi!
Please bear with me for explanation on issue, it starts as a common one, but it's not quite that
I have a project which has its own set of entities that come from two different schemas, they both use the same UserRevEntity in order to save audited entries, so up to there it's fine. I also need to bring in two projects that have their own persistence schemas and bring data from separate DBs, obviously, they have their own UserRevEntity to save audited entries in the schemas.
So, this was working fine on version 4.3.6, but since trying to migrate to version 5.2.8, it just won't work, it complains about having more than one entity with @RevisionEntity annotation.
I'm using JPA and Hibernate, so I don't have a hibernate.cfg.xml file
Any help will be very, very appreciated
EDIT adding code as requested by first reply:
The code for the class on the dependency:
Code:
package org.wwarn.chassis.server;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
import javax.persistence.*;
/**
* Created by suay on 12/16/15.
*/
@Entity
@Table(name = "REVINFOUSER", schema = "chassisCore")
@RevisionEntity(UserRevisionListener.class)
public class UserRevEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@RevisionNumber
private int id;
@RevisionTimestamp
private long timestamp;
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UserRevEntity)) return false;
UserRevEntity that = (UserRevEntity) o;
if (id != that.id) return false;
if (timestamp != that.timestamp) return false;
if (username != null ? !username.equals(that.username) : that.username != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
result = 31 * result + (username != null ? username.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "UserRevEntity{" +
"id=" + id +
", timestamp=" + timestamp +
", username='" + username + '\'' +
'}';
}
}
The code for the class on the actual project:
Code:
package org.wwarn.config.envers;
import org.hibernate.envers.DefaultRevisionEntity;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
import javax.persistence.*;
/**
* Created by suay on 3/22/16.
*/
@Entity
@Table(name = "UserRevEntity", catalog = "molecular")
@RevisionEntity(UserRevisionListener.class)
public class UserRevEntity {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@RevisionNumber
private int id;
@RevisionTimestamp
private long timestamp;
private String username;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UserRevEntity)) return false;
UserRevEntity that = (UserRevEntity) o;
if (id != that.id) return false;
if (timestamp != that.timestamp) return false;
if (username != null ? !username.equals(that.username) : that.username != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
result = 31 * result + (username != null ? username.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "UserRevEntity{" +
"id=" + id +
", timestamp=" + timestamp +
", username='" + username + '\'' +
'}';
}
}
The error I get at the first go is:
Code:
Only one entity may be annotated with @RevisionEntity
If I delete the @RevisionEntity annotation I get the following:
Code:
org.hibernate.MappingException: Repeated column in mapping for entity: StudyEntity_FileEntity_AUD column: file_id (should be mapped with insert="false" update="false")
However if I add insertable = false and updatable = false it insists with same error
If I change the name of the UserRevEntity class on the project, I get the original error too