private void updateIndexes(Object entity) { try { final Class<?> resolvedEntityClass = resolveEntityClass(entity.getClass()); if (resolvedEntityClass != null) { final EntityConfig entityConfig = hiveConfig.getEntityConfig(entity.getClass()); if (indexer.idExists(entityConfig, entityConfig.getId(entity))) indexer.updatePartitionDimensionIndexIfNeeded( hiveConfig.getEntityConfig(resolvedEntityClass), entity); indexer.update(entityConfig, entity); } } catch (HiveLockableException e) { throw new CallbackException(e); } }
private void insertIndexes(Object entity) { try { final Class<?> resolvedEntityClass = resolveEntityClass(entity.getClass()); if (resolvedEntityClass != null) indexer.insert(hiveConfig.getEntityConfig(resolvedEntityClass), entity); } catch (HiveLockableException e) { throw new CallbackException(e); } }
@Override public void onDelete( Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { try { final Class<?> resolvedEntityClass = resolveEntityClass(entity.getClass()); if (resolvedEntityClass != null) indexer.delete(hiveConfig.getEntityConfig(entity.getClass()), entity); } catch (HiveLockableException e) { throw new CallbackException(e); } super.onDelete(entity, id, state, propertyNames, types); }
@SuppressWarnings("unchecked") @Override public void postFlush(Iterator entities) throws CallbackException { while (entities.hasNext()) { Object entity = entities.next(); Class<?> resolvedClass = resolveEntityClass(entity.getClass()); if (resolvedClass != null) { final EntityConfig entityConfig = hiveConfig.getEntityConfig(resolvedClass); if (indexer.exists(entityConfig, entity)) updateIndexes(entity); else insertIndexes(entity); } } super.postFlush(entities); }
@Override public Boolean isTransient(Object entity) { Class<?> clazz = new EntityResolver(hiveConfig).resolveEntityInterface(entity.getClass()); if (clazz != null) return !indexer.exists(this.hiveConfig.getEntityConfig(clazz), entity); return super.isTransient(entity); }