Package org.hibernate.envers

Examples of org.hibernate.envers.RevisionEntity


                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityNamesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();
                revisionInfoClass = pc.getMappedClass();
                Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value());
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()
                        || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
                        || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
                        || modifiedEntityNamesFound.isSet()) {
View Full Code Here


                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityNamesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();
                revisionInfoClass = pc.getMappedClass();
                Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value());
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() ||
                        DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass) ||
                        modifiedEntityNamesFound.isSet()) {
                    // If tracking modified entities parameter is enabled, custom revision info entity is a subtype
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityNamesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();
                revisionInfoClass = pc.getMappedClass();
                Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value());
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() ||
                        DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass) ||
                        modifiedEntityNamesFound.isSet()) {
                    // If tracking modified entities parameter is enabled, custom revision info entity is a subtype
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityNamesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();

                revisionInfoClass = pc.getMappedClass();
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() ||
                        DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass) ||
                        modifiedEntityNamesFound.isSet()) {
                    // If tracking modified entities parameter is enabled, custom revision info entity is a subtype
                    // of DefaultTrackingModifiedEntitiesRevisionEntity class, or @ModifiedEntityNames annotation is used.
                    revisionInfoGenerator = new DefaultTrackingModifiedEntitiesRevisionInfoGenerator(revisionInfoEntityName,
                            revisionInfoClass, revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate(),
                            modifiedEntityNamesData);
                    globalCfg.setTrackEntitiesChangedInRevisionEnabled(true);
                } else {
                    revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
                            revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate());
                }
            }
        }

        // In case of a custom revision info generator, the mapping will be null.
View Full Code Here

      }
      catch (ClassNotFoundException e) {
        throw new MappingException( e );
      }

      final RevisionEntity revisionEntity = clazz.getAnnotation( RevisionEntity.class );
      if ( revisionEntity != null ) {
        if ( revisionEntityFound ) {
          throw new MappingException( "Only one entity may be annotated with @RevisionEntity!" );
        }

        // Checking if custom revision entity isn't audited
        if ( clazz.getAnnotation( Audited.class ) != null ) {
          throw new MappingException( "An entity annotated with @RevisionEntity cannot be audited!" );
        }

        revisionEntityFound = true;

        final MutableBoolean revisionNumberFound = new MutableBoolean();
        final MutableBoolean revisionTimestampFound = new MutableBoolean();
        final MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

        searchForRevisionInfoCfg(
            clazz,
            reflectionManager,
            revisionNumberFound,
            revisionTimestampFound,
            modifiedEntityNamesFound
        );

        if ( !revisionNumberFound.isSet() ) {
          throw new MappingException(
              "An entity annotated with @RevisionEntity must have a field annotated " +
                  "with @RevisionNumber!"
          );
        }

        if ( !revisionTimestampFound.isSet() ) {
          throw new MappingException(
              "An entity annotated with @RevisionEntity must have a field annotated " +
                  "with @RevisionTimestamp!"
          );
        }

        revisionInfoEntityName = pc.getEntityName();
        revisionInfoClass = pc.getMappedClass();
        final Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass( revisionEntity.value() );
        revisionInfoTimestampType = pc.getProperty( revisionInfoTimestampData.getName() ).getType();
        if ( globalCfg.isTrackEntitiesChangedInRevision()
            || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class
            .isAssignableFrom( revisionInfoClass ))
            || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();

                revisionInfoClass = pc.getMappedClass();
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
                        revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate());
            }
        }

        // In case of a custom revision info generator, the mapping will be null.
        Document revisionInfoXmlMapping = null;
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();

                revisionInfoClass = pc.getMappedClass();
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
                        revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate());
            }
        }

        // In case of a custom revision info generator, the mapping will be null.
        Document revisionInfoXmlMapping = null;
View Full Code Here

      }
      catch (ClassNotFoundException e) {
        throw new MappingException( e );
      }

      final RevisionEntity revisionEntity = clazz.getAnnotation( RevisionEntity.class );
      if ( revisionEntity != null ) {
        if ( revisionEntityFound ) {
          throw new MappingException( "Only one entity may be annotated with @RevisionEntity!" );
        }

        // Checking if custom revision entity isn't audited
        if ( clazz.getAnnotation( Audited.class ) != null ) {
          throw new MappingException( "An entity annotated with @RevisionEntity cannot be audited!" );
        }

        revisionEntityFound = true;

        final MutableBoolean revisionNumberFound = new MutableBoolean();
        final MutableBoolean revisionTimestampFound = new MutableBoolean();
        final MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

        searchForRevisionInfoCfg(
            clazz,
            reflectionManager,
            revisionNumberFound,
            revisionTimestampFound,
            modifiedEntityNamesFound
        );

        if ( !revisionNumberFound.isSet() ) {
          throw new MappingException(
              "An entity annotated with @RevisionEntity must have a field annotated " +
                  "with @RevisionNumber!"
          );
        }

        if ( !revisionTimestampFound.isSet() ) {
          throw new MappingException(
              "An entity annotated with @RevisionEntity must have a field annotated " +
                  "with @RevisionTimestamp!"
          );
        }

        revisionInfoEntityName = pc.getEntityName();
        revisionInfoClass = pc.getMappedClass();
        final Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass( revisionEntity.value() );
        revisionInfoTimestampType = pc.getProperty( revisionInfoTimestampData.getName() ).getType();
        if ( globalCfg.isTrackEntitiesChangedInRevision()
            || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class
            .isAssignableFrom( revisionInfoClass ))
            || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityNamesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityNamesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();
                revisionInfoClass = pc.getMappedClass();
                Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value());
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()
                        || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
                        || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
                        || modifiedEntityNamesFound.isSet()) {
View Full Code Here

                clazz = reflectionManager.classForName(pc.getClassName(), this.getClass());
            } catch (ClassNotFoundException e) {
                throw new MappingException(e);
            }

            RevisionEntity revisionEntity = clazz.getAnnotation(RevisionEntity.class);
            if (revisionEntity != null) {
                if (revisionEntityFound) {
                    throw new MappingException("Only one entity may be annotated with @RevisionEntity!");
                }

                // Checking if custom revision entity isn't audited
                if (clazz.getAnnotation(Audited.class) != null) {
                    throw new MappingException("An entity annotated with @RevisionEntity cannot be audited!");
                }

                revisionEntityFound = true;

                MutableBoolean revisionNumberFound = new MutableBoolean();
                MutableBoolean revisionTimestampFound = new MutableBoolean();
                MutableBoolean modifiedEntityTypesFound = new MutableBoolean();

                searchForRevisionInfoCfg(clazz, reflectionManager, revisionNumberFound, revisionTimestampFound, modifiedEntityTypesFound);

                if (!revisionNumberFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionNumber!");
                }

                if (!revisionTimestampFound.isSet()) {
                    throw new MappingException("An entity annotated with @RevisionEntity must have a field annotated " +
                            "with @RevisionTimestamp!");
                }

                revisionInfoEntityName = pc.getEntityName();

                revisionInfoClass = pc.getMappedClass();
                revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
                if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() ||
                        DefaultTrackingModifiedTypesRevisionEntity.class.isAssignableFrom(revisionInfoClass) ||
                        modifiedEntityTypesFound.isSet()) {
                    // If tracking modified entities parameter is enabled, custom revision info entity is a subtype
                    // of DefaultTrackingModifiedTypesRevisionEntity class, or @ModifiedEntityTypes annotation is used.
                    revisionInfoGenerator = new DefaultTrackingModifiedTypesRevisionInfoGenerator(revisionInfoEntityName,
                            revisionInfoClass, revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate(),
                            modifiedEntityTypesData);
                    globalCfg.setTrackEntitiesChangedInRevisionEnabled(true);
                } else {
                    revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
                            revisionEntity.value(), revisionInfoTimestampData, isTimestampAsDate());
                }
            }
        }

        // In case of a custom revision info generator, the mapping will be null.
View Full Code Here

TOP

Related Classes of org.hibernate.envers.RevisionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.