Search in sources :

Example 76 with Serializable

use of java.io.Serializable in project silk by jbee.

the class TestMockingBinds method wildcardBindsDoFallBackToMostGeneralIfRequired.

@Test
public void wildcardBindsDoFallBackToMostGeneralIfRequired() {
    Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
    Serializable mock = injector.resolve(dependency(Serializable.class));
    assertTrue(isProxyClass(mock.getClass()));
    assertEquals(Object.class.getCanonicalName(), mock.toString());
}
Also used : Serializable(java.io.Serializable) Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 77 with Serializable

use of java.io.Serializable in project hibernate-orm by hibernate.

the class EntityInstantiator method replaceNonAuditIdProxies.

@SuppressWarnings({ "unchecked" })
private void replaceNonAuditIdProxies(Map versionsEntity, Number revision) {
    final Map originalId = (Map) versionsEntity.get(enversService.getAuditEntitiesConfiguration().getOriginalIdPropName());
    for (Object key : originalId.keySet()) {
        final Object value = originalId.get(key);
        if (value instanceof HibernateProxy) {
            final HibernateProxy hibernateProxy = (HibernateProxy) value;
            final LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer();
            final String entityName = initializer.getEntityName();
            final Serializable entityId = initializer.getIdentifier();
            if (enversService.getEntitiesConfigurations().isVersioned(entityName)) {
                final String entityClassName = enversService.getEntitiesConfigurations().get(entityName).getEntityClassName();
                final Class entityClass = ReflectionTools.loadClass(entityClassName, enversService.getClassLoaderService());
                final ToOneDelegateSessionImplementor delegate = new ToOneDelegateSessionImplementor(versionsReader, entityClass, entityId, revision, RevisionType.DEL.equals(versionsEntity.get(enversService.getAuditEntitiesConfiguration().getRevisionTypePropName())), enversService);
                originalId.put(key, versionsReader.getSessionImplementor().getFactory().getMetamodel().entityPersister(entityName).createProxy(entityId, delegate));
            }
        }
    }
}
Also used : ToOneDelegateSessionImplementor(org.hibernate.envers.internal.entities.mapper.relation.lazy.ToOneDelegateSessionImplementor) LazyInitializer(org.hibernate.proxy.LazyInitializer) Serializable(java.io.Serializable) Map(java.util.Map) HibernateProxy(org.hibernate.proxy.HibernateProxy)

Example 78 with Serializable

use of java.io.Serializable in project hibernate-orm by hibernate.

the class AbstractOneToOneMapper method nullSafeMapToEntityFromMap.

@Override
public void nullSafeMapToEntityFromMap(EnversService enversService, Object obj, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
    final EntityInfo referencedEntity = getEntityInfo(enversService, referencedEntityName);
    Object value;
    try {
        value = queryForReferencedEntity(versionsReader, referencedEntity, (Serializable) primaryKey, revision);
    } catch (NoResultException e) {
        value = null;
    } catch (NonUniqueResultException e) {
        throw new AuditException("Many versions results for one-to-one relationship " + entityName + "." + getPropertyData().getBeanName() + ".", e);
    }
    setPropertyValue(obj, value);
}
Also used : NonUniqueResultException(org.hibernate.NonUniqueResultException) Serializable(java.io.Serializable) AuditException(org.hibernate.envers.exception.AuditException) NoResultException(javax.persistence.NoResultException)

Example 79 with Serializable

use of java.io.Serializable in project hibernate-orm by hibernate.

the class EntityChangeNotifier method entityChanged.

/**
	 * Notifies {@link RevisionInfoGenerator} about changes made in the current revision. Provides information
	 * about modified entity class, entity name and its id, as well as {@link org.hibernate.envers.RevisionType}
	 * and revision log entity.
	 *
	 * @param session Active session.
	 * @param currentRevisionData Revision log entity.
	 * @param vwu Performed work unit.
	 */
public void entityChanged(Session session, Object currentRevisionData, AuditWorkUnit vwu) {
    Serializable entityId = vwu.getEntityId();
    if (entityId instanceof PersistentCollectionChangeWorkUnit.PersistentCollectionChangeWorkUnitId) {
        // Notify about a change in collection owner entity.
        entityId = ((PersistentCollectionChangeWorkUnit.PersistentCollectionChangeWorkUnitId) entityId).getOwnerId();
    }
    final Class entityClass = EntityTools.getEntityClass(sessionImplementor, vwu.getEntityName());
    revisionInfoGenerator.entityChanged(entityClass, vwu.getEntityName(), entityId, vwu.getRevisionType(), currentRevisionData);
}
Also used : Serializable(java.io.Serializable) PersistentCollectionChangeWorkUnit(org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit)

Example 80 with Serializable

use of java.io.Serializable in project hibernate-orm by hibernate.

the class BaseEnversCollectionEventListener method generateBidirectionalCollectionChangeWorkUnits.

private void generateBidirectionalCollectionChangeWorkUnits(AuditProcess auditProcess, AbstractCollectionEvent event, PersistentCollectionChangeWorkUnit workUnit, RelationDescription rd) {
    // Checking if this is enabled in configuration ...
    if (!getEnversService().getGlobalConfiguration().isGenerateRevisionsForCollections()) {
        return;
    }
    // relDesc can be null if this is a collection of simple values (not a relation).
    if (rd != null && rd.isBidirectional()) {
        final String relatedEntityName = rd.getToEntityName();
        final IdMapper relatedIdMapper = getEnversService().getEntitiesConfigurations().get(relatedEntityName).getIdMapper();
        final Set<String> toPropertyNames = getEnversService().getEntitiesConfigurations().getToPropertyNames(event.getAffectedOwnerEntityName(), rd.getFromPropertyName(), relatedEntityName);
        final String toPropertyName = toPropertyNames.iterator().next();
        for (PersistentCollectionChangeData changeData : workUnit.getCollectionChanges()) {
            final Object relatedObj = changeData.getChangedElement();
            final Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);
            auditProcess.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), event.getSession().bestGuessEntityName(relatedObj), toPropertyName, getEnversService(), relatedId, relatedObj));
        }
    }
}
Also used : Serializable(java.io.Serializable) IdMapper(org.hibernate.envers.internal.entities.mapper.id.IdMapper) PersistentCollectionChangeData(org.hibernate.envers.internal.entities.mapper.PersistentCollectionChangeData) CollectionChangeWorkUnit(org.hibernate.envers.internal.synchronization.work.CollectionChangeWorkUnit) PersistentCollectionChangeWorkUnit(org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit)

Aggregations

Serializable (java.io.Serializable)1052 Test (org.junit.Test)267 HashMap (java.util.HashMap)226 ArrayList (java.util.ArrayList)181 Map (java.util.Map)116 Metacard (ddf.catalog.data.Metacard)89 List (java.util.List)80 IOException (java.io.IOException)70 HashSet (java.util.HashSet)68 Session (org.hibernate.Session)62 Set (java.util.Set)46 Date (java.util.Date)40 Task (org.apache.hadoop.hive.ql.exec.Task)40 ByteArrayInputStream (java.io.ByteArrayInputStream)38 LinkedHashMap (java.util.LinkedHashMap)36 EntityPersister (org.hibernate.persister.entity.EntityPersister)34 ObjectInputStream (java.io.ObjectInputStream)33 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)31 Iterator (java.util.Iterator)31 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)28