HHH-3570: more renaming, some compatibility classes

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15506 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2008-11-04 22:11:07 +00:00
parent 4bad2d2b7e
commit ba3aaecbe4
24 changed files with 499 additions and 68 deletions

View File

@ -26,7 +26,7 @@ package org.hibernate.envers;
import java.util.Date;
import java.util.List;
import org.hibernate.envers.exception.NotVersionedException;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.exception.RevisionDoesNotExistException;
import org.hibernate.envers.query.AuditQueryCreator;
@ -43,11 +43,11 @@ public interface AuditReader {
* if not all properties are versioned) or null, if an entity with that id didn't exist at that
* revision.
* @throws IllegalArgumentException If cls or primaryKey is null or revision is less or equal to 0.
* @throws NotVersionedException When entities of the given class are not versioned.
* @throws NotAuditedException When entities of the given class are not audited.
* @throws IllegalStateException If the associated entity manager is closed.
*/
<T> T find(Class<T> cls, Object primaryKey, Number revision) throws
IllegalArgumentException, NotVersionedException, IllegalStateException;
IllegalArgumentException, NotAuditedException, IllegalStateException;
/**
* Get a list of revision numbers, at which an entity was modified.
@ -55,12 +55,12 @@ public interface AuditReader {
* @param primaryKey Primary key of the entity.
* @return A list of revision numbers, at which the entity was modified, sorted in ascending order (so older
* revisions come first).
* @throws NotVersionedException When entities of the given class are not versioned.
* @throws NotAuditedException When entities of the given class are not audited.
* @throws IllegalArgumentException If cls or primaryKey is null.
* @throws IllegalStateException If the associated entity manager is closed.
*/
List<Number> getRevisions(Class<?> cls, Object primaryKey)
throws IllegalArgumentException, NotVersionedException, IllegalStateException;
throws IllegalArgumentException, NotAuditedException, IllegalStateException;
/**
* Get the date, at which a revision was created.
@ -102,7 +102,7 @@ public interface AuditReader {
/**
*
* @return A query creator, associated with this VersionsReader instance, with which queries can be
* @return A query creator, associated with this AuditReader instance, with which queries can be
* created and later executed. Shouldn't be used after the associated Session or EntityManager
* is closed.
*/

View File

@ -25,7 +25,7 @@ package org.hibernate.envers;
import javax.persistence.EntityManager;
import org.hibernate.envers.event.VersionsEventListener;
import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.reader.AuditReaderImpl;
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
@ -48,7 +48,7 @@ public class AuditReaderFactory {
* @param session An open session.
* @return A versions reader associated with the given sesison. It shouldn't be used
* after the session is closed.
* @throws org.hibernate.envers.exception.AuditException When the given required listeners aren't installed.
* @throws AuditException When the given required listeners aren't installed.
*/
public static AuditReader get(Session session) throws AuditException {
SessionImplementor sessionImpl = (SessionImplementor) session;
@ -56,16 +56,16 @@ public class AuditReaderFactory {
EventListeners listeners = sessionImpl.getListeners();
for (PostInsertEventListener listener : listeners.getPostInsertEventListeners()) {
if (listener instanceof VersionsEventListener) {
if (arrayIncludesInstanceOf(listeners.getPostUpdateEventListeners(), VersionsEventListener.class) &&
arrayIncludesInstanceOf(listeners.getPostDeleteEventListeners(), VersionsEventListener.class)) {
return new AuditReaderImpl(((VersionsEventListener) listener).getVerCfg(), session,
if (listener instanceof AuditEventListener) {
if (arrayIncludesInstanceOf(listeners.getPostUpdateEventListeners(), AuditEventListener.class) &&
arrayIncludesInstanceOf(listeners.getPostDeleteEventListeners(), AuditEventListener.class)) {
return new AuditReaderImpl(((AuditEventListener) listener).getVerCfg(), session,
sessionImpl);
}
}
}
throw new AuditException("You need install the org.hibernate.envers.event.VersionsEventListener " +
throw new AuditException("You need to install the org.hibernate.envers.event.AuditEventListener " +
"class as post insert, update and delete event listener.");
}
@ -74,7 +74,7 @@ public class AuditReaderFactory {
* @param entityManager An open entity manager.
* @return A versions reader associated with the given entity manager. It shouldn't be used
* after the entity manager is closed.
* @throws org.hibernate.envers.exception.AuditException When the given entity manager is not based on Hibernate, or if the required
* @throws AuditException When the given entity manager is not based on Hibernate, or if the required
* listeners aren't installed.
*/
public static AuditReader get(EntityManager entityManager) throws AuditException {

View File

@ -29,8 +29,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* When applied to a class, indicates that all of its properties should be versioned.
* When applied to a field, indicates that this field should be versioned.
* When applied to a class, indicates that all of its properties should be audited.
* When applied to a field, indicates that this field should be audited.
* @author Adam Warski (adam at warski dot org)
*/
@Retention(RetentionPolicy.RUNTIME)

View File

@ -60,7 +60,7 @@ import org.hibernate.persister.entity.EntityPersister;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsEventListener implements PostInsertEventListener, PostUpdateEventListener,
public class AuditEventListener implements PostInsertEventListener, PostUpdateEventListener,
PostDeleteEventListener, PreCollectionUpdateEventListener, PreCollectionRemoveEventListener,
PostCollectionRecreateEventListener, Initializable {
private AuditConfiguration verCfg;

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.envers.exception;
import org.hibernate.HibernateException;
import org.jboss.envers.exception.VersionsException;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class AuditException extends HibernateException {
public class AuditException extends VersionsException {
public AuditException(String message) {
super(message);
}

View File

@ -0,0 +1,35 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.exception;
import org.jboss.envers.exception.NotVersionedException;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class NotAuditedException extends NotVersionedException {
public NotAuditedException(String entityName, String message) {
super(entityName, message);
}
}

View File

@ -28,25 +28,12 @@ import java.util.Date;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionDoesNotExistException extends AuditException {
private Number revision;
private Date date;
public class RevisionDoesNotExistException extends org.jboss.envers.exception.RevisionDoesNotExistException {
public RevisionDoesNotExistException(Number revision) {
super("Revision " + revision + " does not exist.");
this.revision = revision;
super(revision);
}
public RevisionDoesNotExistException(Date date) {
super("There is no revision before or at " + date + ".");
this.date = date;
}
public Number getRevision() {
return revision;
}
public Date getDate() {
return date;
super(date);
}
}

View File

@ -34,12 +34,12 @@ import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
* @author Adam Warski (adam at warski dot org)
*/
public class AuditQueryCreator {
private final AuditConfiguration verCfg;
private final AuditReaderImplementor versionsReaderImplementor;
private final AuditConfiguration auditCfg;
private final AuditReaderImplementor auditReaderImplementor;
public AuditQueryCreator(AuditConfiguration verCfg, AuditReaderImplementor versionsReaderImplementor) {
this.verCfg = verCfg;
this.versionsReaderImplementor = versionsReaderImplementor;
public AuditQueryCreator(AuditConfiguration auditCfg, AuditReaderImplementor auditReaderImplementor) {
this.auditCfg = auditCfg;
this.auditReaderImplementor = auditReaderImplementor;
}
/**
@ -54,7 +54,7 @@ public class AuditQueryCreator {
public AuditQuery forEntitiesAtRevision(Class<?> c, Number revision) {
checkNotNull(revision, "Entity revision");
checkPositive(revision, "Entity revision");
return new EntitiesAtRevisionQuery(verCfg, versionsReaderImplementor, c, revision);
return new EntitiesAtRevisionQuery(auditCfg, auditReaderImplementor, c, revision);
}
/**
@ -78,6 +78,6 @@ public class AuditQueryCreator {
* unless an order or projection is added.
*/
public AuditQuery forRevisionsOfEntity(Class<?> c, boolean selectEntitiesOnly, boolean selectDeletedEntities) {
return new RevisionsOfEntityQuery(verCfg, versionsReaderImplementor, c, selectEntitiesOnly,selectDeletedEntities);
return new RevisionsOfEntityQuery(auditCfg, auditReaderImplementor, c, selectEntitiesOnly,selectDeletedEntities);
}
}

View File

@ -50,7 +50,7 @@ import org.hibernate.Query;
/**
* @author Adam Warski (adam at warski dot org)
*/
public abstract class AbstractVersionsQuery implements AuditQuery {
public abstract class AbstractAuditQuery implements AuditQuery {
protected EntityInstantiator entityInstantiator;
protected List<AuditCriterion> criterions;
@ -64,7 +64,7 @@ public abstract class AbstractVersionsQuery implements AuditQuery {
protected final AuditConfiguration verCfg;
private final AuditReaderImplementor versionsReader;
protected AbstractVersionsQuery(AuditConfiguration verCfg, AuditReaderImplementor versionsReader,
protected AbstractAuditQuery(AuditConfiguration verCfg, AuditReaderImplementor versionsReader,
Class<?> cls) {
this.verCfg = verCfg;
this.versionsReader = versionsReader;

View File

@ -36,7 +36,7 @@ import org.hibernate.envers.tools.query.QueryBuilder;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class EntitiesAtRevisionQuery extends AbstractVersionsQuery {
public class EntitiesAtRevisionQuery extends AbstractAuditQuery {
private final Number revision;
public EntitiesAtRevisionQuery(AuditConfiguration verCfg,

View File

@ -39,7 +39,7 @@ import org.hibernate.proxy.HibernateProxy;
/**
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionsOfEntityQuery extends AbstractVersionsQuery {
public class RevisionsOfEntityQuery extends AbstractAuditQuery {
private final boolean selectEntitiesOnly;
private final boolean selectDeletedEntities;

View File

@ -28,11 +28,10 @@ import java.util.List;
import javax.persistence.NoResultException;
import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.exception.NotVersionedException;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.exception.RevisionDoesNotExistException;
import org.hibernate.envers.exception.AuditException;
import org.hibernate.envers.query.RevisionProperty;
import org.hibernate.envers.query.AuditQueryCreator;
import org.hibernate.envers.query.AuditRestrictions;
import static org.hibernate.envers.tools.ArgumentsTools.checkNotNull;
import static org.hibernate.envers.tools.ArgumentsTools.checkPositive;
@ -41,6 +40,7 @@ import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
import org.jboss.envers.query.VersionsQueryCreator;
/**
* @author Adam Warski (adam at warski dot org)
@ -80,7 +80,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
@SuppressWarnings({"unchecked"})
public <T> T find(Class<T> cls, Object primaryKey, Number revision) throws
IllegalArgumentException, NotVersionedException, IllegalStateException {
IllegalArgumentException, NotAuditedException, IllegalStateException {
checkNotNull(cls, "Entity class");
checkNotNull(primaryKey, "Primary key");
checkNotNull(revision, "Entity revision");
@ -90,7 +90,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
String entityName = cls.getName();
if (!verCfg.getEntCfg().isVersioned(entityName)) {
throw new NotVersionedException(entityName, entityName + " is not versioned!");
throw new NotAuditedException(entityName, entityName + " is not versioned!");
}
if (firstLevelCache.contains(entityName, revision, primaryKey)) {
@ -113,7 +113,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
@SuppressWarnings({"unchecked"})
public List<Number> getRevisions(Class<?> cls, Object primaryKey)
throws IllegalArgumentException, NotVersionedException, IllegalStateException {
throws IllegalArgumentException, NotAuditedException, IllegalStateException {
// todo: if a class is not versioned from the beginning, there's a missing ADD rev - what then?
checkNotNull(cls, "Entity class");
checkNotNull(primaryKey, "Primary key");
@ -122,7 +122,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
String entityName = cls.getName();
if (!verCfg.getEntCfg().isVersioned(entityName)) {
throw new NotVersionedException(entityName, entityName + " is not versioned!");
throw new NotAuditedException(entityName, entityName + " is not versioned!");
}
return createQuery().forRevisionsOfEntity(cls, false, true)
@ -191,7 +191,7 @@ public class AuditReaderImpl implements AuditReaderImplementor {
}
}
public AuditQueryCreator createQuery() {
return new AuditQueryCreator(verCfg, this);
public VersionsQueryCreator createQuery() {
return new VersionsQueryCreator(verCfg, this);
}
}

View File

@ -27,12 +27,13 @@ import org.hibernate.envers.AuditReader;
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
import org.jboss.envers.VersionsReader;
/**
* An interface exposed by a VersionsReader to library-facing classes.
* @author Adam Warski (adam at warski dot org)
*/
public interface AuditReaderImplementor extends AuditReader {
public interface AuditReaderImplementor extends AuditReader, VersionsReader {
SessionImplementor getSessionImplementor();
Session getSession();
FirstLevelCache getFirstLevelCache();

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
/**
* @see org.hibernate.envers.ModificationStore
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public enum ModificationStore {
FULL
}

View File

@ -0,0 +1,41 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @see org.hibernate.envers.Audited
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
public @interface Versioned {
public abstract ModificationStore modStore() default ModificationStore.FULL;
}

View File

@ -0,0 +1,57 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import org.hibernate.envers.AuditReader;
import org.jboss.envers.query.VersionsQueryCreator;
import org.jboss.envers.exception.NotVersionedException;
import org.jboss.envers.exception.RevisionDoesNotExistException;
import java.util.List;
import java.util.Date;
/**
* @see org.hibernate.envers.AuditReader
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public interface VersionsReader extends AuditReader {
<T> T find(Class<T> cls, Object primaryKey, Number revision) throws
IllegalArgumentException, NotVersionedException, IllegalStateException;
List<Number> getRevisions(Class<?> cls, Object primaryKey)
throws IllegalArgumentException, NotVersionedException, IllegalStateException;
Date getRevisionDate(Number revision) throws IllegalArgumentException, RevisionDoesNotExistException,
IllegalStateException;
Number getRevisionNumberForDate(Date date) throws IllegalStateException, RevisionDoesNotExistException,
IllegalArgumentException;
<T> T findRevision(Class<T> revisionEntityClass, Number revision) throws IllegalArgumentException,
RevisionDoesNotExistException, IllegalStateException;
VersionsQueryCreator createQuery();
}

View File

@ -0,0 +1,96 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers;
import javax.persistence.EntityManager;
import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.envers.reader.AuditReaderImpl;
import static org.hibernate.envers.tools.ArraysTools.arrayIncludesInstanceOf;
import org.hibernate.Session;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.event.EventListeners;
import org.hibernate.event.PostInsertEventListener;
import org.jboss.envers.exception.VersionsException;
/**
* @see org.hibernate.envers.AuditReaderFactory
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsReaderFactory {
private VersionsReaderFactory() { }
/**
* Create a versions reader associated with an open session.
* <b>WARNING:</b> Using Envers with Hibernate (not with Hibernate Entity Manager/JPA) is experimental,
* if possible, use {@link VersionsReaderFactory#get(javax.persistence.EntityManager)}.
* @param session An open session.
* @return A versions reader associated with the given sesison. It shouldn't be used
* after the session is closed.
* @throws org.hibernate.envers.exception.AuditException When the given required listeners aren't installed.
*/
public static VersionsReader get(Session session) throws VersionsException {
SessionImplementor sessionImpl = (SessionImplementor) session;
EventListeners listeners = sessionImpl.getListeners();
for (PostInsertEventListener listener : listeners.getPostInsertEventListeners()) {
if (listener instanceof AuditEventListener) {
if (arrayIncludesInstanceOf(listeners.getPostUpdateEventListeners(), AuditEventListener.class) &&
arrayIncludesInstanceOf(listeners.getPostDeleteEventListeners(), AuditEventListener.class)) {
return new AuditReaderImpl(((AuditEventListener) listener).getVerCfg(), session,
sessionImpl);
}
}
}
throw new VersionsException("You need install the org.hibernate.envers.event.VersionsEventListener " +
"class as post insert, update and delete event listener.");
}
/**
* Create a versions reader associated with an open entity manager.
* @param entityManager An open entity manager.
* @return A versions reader associated with the given entity manager. It shouldn't be used
* after the entity manager is closed.
* @throws org.hibernate.envers.exception.AuditException When the given entity manager is not based on Hibernate, or if the required
* listeners aren't installed.
*/
public static VersionsReader get(EntityManager entityManager) throws VersionsException {
if (entityManager.getDelegate() instanceof Session) {
return get((Session) entityManager.getDelegate());
}
if (entityManager.getDelegate() instanceof EntityManager) {
if (entityManager.getDelegate() instanceof Session) {
return get((Session) entityManager.getDelegate());
}
}
throw new VersionsException("Hibernate EntityManager not present!");
}
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.event;
import org.hibernate.envers.event.AuditEventListener;
/**
* @see AuditEventListener
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsEventListener extends AuditEventListener { }

View File

@ -21,20 +21,25 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.envers.exception;
package org.jboss.envers.exception;
import org.hibernate.envers.exception.AuditException;
/**
* @see org.hibernate.envers.exception.NotAuditedException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class NotVersionedException extends AuditException {
public class NotVersionedException extends VersionsException {
private final String entityName;
public NotVersionedException(String entityName, String message) {
super(message);
this.entityName = entityName;
this.entityName = entityName;
}
public String getEntityName() {
return entityName;
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.exception;
import java.util.Date;
/**
* @see org.hibernate.envers.exception.RevisionDoesNotExistException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class RevisionDoesNotExistException extends VersionsException {
private Number revision;
private Date date;
public RevisionDoesNotExistException(Number revision) {
super("Revision " + revision + " does not exist.");
this.revision = revision;
}
public RevisionDoesNotExistException(Date date) {
super("There is no revision before or at " + date + ".");
this.date = date;
}
public Number getRevision() {
return revision;
}
public Date getDate() {
return date;
}
}

View File

@ -0,0 +1,46 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.exception;
import org.hibernate.HibernateException;
/**
* @see org.hibernate.envers.exception.AuditException
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsException extends HibernateException {
public VersionsException(String message) {
super(message);
}
public VersionsException(String message, Throwable cause) {
super(message, cause);
}
public VersionsException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,40 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.jboss.envers.query;
import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.envers.query.AuditQueryCreator;
import org.hibernate.envers.reader.AuditReaderImplementor;
/**
* @link AuditQueryCreator
* @deprecated
* @author Adam Warski (adam at warski dot org)
*/
public class VersionsQueryCreator extends AuditQueryCreator {
public VersionsQueryCreator(AuditConfiguration verCfg, AuditReaderImplementor versionsReaderImplementor) {
super(verCfg, versionsReaderImplementor);
}
}

View File

@ -25,7 +25,7 @@ package org.hibernate.envers.test.integration.basic;
import javax.persistence.EntityManager;
import org.hibernate.envers.exception.NotVersionedException;
import org.hibernate.envers.exception.NotAuditedException;
import org.hibernate.envers.test.AbstractEntityTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -58,12 +58,12 @@ public class NotVersioned extends AbstractEntityTest {
em.getTransaction().commit();
}
@Test(expectedExceptions = NotVersionedException.class)
@Test(expectedExceptions = NotAuditedException.class)
public void testRevisionsCounts() {
getVersionsReader().getRevisions(BasicTestEntity3.class, id1);
}
@Test(expectedExceptions = NotVersionedException.class)
@Test(expectedExceptions = NotAuditedException.class)
public void testHistoryOfId1() {
getVersionsReader().find(BasicTestEntity3.class, id1, 1);
}

View File

@ -24,22 +24,22 @@
<property name="connection.password"></property>-->
<event type="post-insert">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-update">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-delete">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="pre-collection-update">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="pre-collection-remove">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
<event type="post-collection-recreate">
<listener class="org.hibernate.envers.event.VersionsEventListener" />
<listener class="org.hibernate.envers.event.AuditEventListener" />
</event>
</session-factory>
</hibernate-configuration>