类javax.persistence.PostLoad源码实例Demo

下面列出了怎么用javax.persistence.PostLoad的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: heimdall   文件: Interceptor.java
@PostLoad
private void initValuesLoad() {
     
     switch (lifeCycle) {
          case API:
               referenceId = api.getId();
               break;
          case PLAN:
               referenceId = plan.getId();
               break;
          case RESOURCE:
               referenceId = resource.getId();
               break;
          case OPERATION:
               referenceId = operation.getId();
               break;
          default:
               break;
     }
}
 
/**
 * Initializes the registered service with default values
 * for fields that are unspecified. Only triggered by JPA.
 * @since 4.1
 */
@PostLoad
public final void postLoad() {
    if (this.proxyPolicy == null) {
        this.proxyPolicy = new RefuseRegisteredServiceProxyPolicy();
    }
    if (this.usernameAttributeProvider == null) {
        this.usernameAttributeProvider = new DefaultRegisteredServiceUsernameProvider();
    }
    if (this.logoutType == null) {
        this.logoutType = LogoutType.BACK_CHANNEL;
    }
    if (this.requiredHandlers == null) {
        this.requiredHandlers = new HashSet<>();
    }
    if (this.accessStrategy == null) {
        this.accessStrategy = new DefaultRegisteredServiceAccessStrategy();
    }
    if (this.attributeReleasePolicy == null) {
        this.attributeReleasePolicy = new ReturnAllowedAttributeReleasePolicy();
    }
}
 
源代码3 项目: cloud-espm-v2   文件: Product.java
@PostLoad
private void postLoad() {
	EntityManagerFactory emf = Utility.getEntityManagerFactory();
	EntityManager em = emf.createEntityManager();
	try {
		ProductText productText = getProductText(em);
		if (productText != null) {
			this.name = productText.getName();
			this.shortDescription = productText.getShortDescription();
			this.longDescription = productText.getLongDescription();
		} else {
			this.name = "";
			this.shortDescription = "";
			this.longDescription = "";
		}
	} finally {
		em.close();
	}
}
 
源代码4 项目: HA-DB   文件: CheckingEntityListener.java
@PostLoad
public void checking(Object target) {
	AnnotationCheckingMetadata metadata = AnnotationCheckingMetadata.getMetadata(target.getClass());
	if (metadata.isCheckable()) {
		StringBuilder sb = new StringBuilder();
		for (Field field : metadata.getCheckedFields()) {
			ReflectionUtils.makeAccessible(field);
			Object value = ReflectionUtils.getField(field, target);
			if (value instanceof Date) {
				throw new RuntimeException("不支持时间类型字段解密!");
			}
			sb.append(value).append(" - ");
		}
		sb.append(MD5_KEY);
		LOGGER.debug("验证数据:" + sb);
		String hex = MD5Utils.encode(sb.toString());
		Field checksumField = metadata.getCheckableField();
		ReflectionUtils.makeAccessible(checksumField);
		String checksum = (String) ReflectionUtils.getField(checksumField, target);
		if (!checksum.equals(hex)) {
			//throw new RuntimeException("数据验证失败!");
		}
	}
}
 
源代码5 项目: warpdb   文件: WarpDbCRUDAndCallbackTest.java
@Test
public void testLoad() throws Exception {
	String[] ids = { User.nextId(), User.nextId(), User.nextId(), User.nextId() };
	for (int i = 0; i < ids.length; i++) {
		User user = new User();
		user.id = ids[i];
		user.name = "Mr No." + i;
		user.email = "no." + i + "@somewhere.org";
		warpdb.insert(user);
	}
	// test get & fetch:
	User u1 = warpdb.get(User.class, ids[0]);
	assertTrue(u1.callbacks.contains(PostLoad.class));
	User u2 = warpdb.fetch(User.class, ids[1]);
	assertTrue(u2.callbacks.contains(PostLoad.class));
	// test list:
	List<User> us = warpdb.list(User.class, "SELECT * FROM User where id>?", ids[1]);
	assertEquals(2, us.size());
	assertTrue(us.get(0).callbacks.contains(PostLoad.class));
	assertTrue(us.get(1).callbacks.contains(PostLoad.class));
	// test criteria:
	List<User> users = warpdb.from(User.class).where("id>?", ids[1]).list();
	assertEquals(2, users.size());
	assertTrue(users.get(0).callbacks.contains(PostLoad.class));
	assertTrue(users.get(1).callbacks.contains(PostLoad.class));
}
 
源代码6 项目: nomulus   文件: DomainBase.java
@PostLoad
void postLoad() {
  // Reconstitute the contact list.
  ImmutableSet.Builder<DesignatedContact> contactsBuilder =
      new ImmutableSet.Builder<DesignatedContact>();

  if (registrantContact != null) {
    contactsBuilder.add(
        DesignatedContact.create(DesignatedContact.Type.REGISTRANT, registrantContact));
  }
  if (billingContact != null) {
    contactsBuilder.add(DesignatedContact.create(DesignatedContact.Type.BILLING, billingContact));
  }
  if (techContact != null) {
    contactsBuilder.add(DesignatedContact.create(DesignatedContact.Type.TECH, techContact));
  }
  if (adminContact != null) {
    contactsBuilder.add(DesignatedContact.create(DesignatedContact.Type.ADMIN, adminContact));
  }

  allContacts = contactsBuilder.build();
}
 
源代码7 项目: spring-cloud-dataflow   文件: TaskDefinition.java
@PostLoad
public void initialize() {
	Map<String, String> properties = new HashMap<>();
	TaskNode taskNode = new TaskParser(this.taskName, this.dslText, true, true).parse();
	if (taskNode.isComposed()) {
		setRegisteredAppName(this.taskName);
	}
	else {
		TaskAppNode singleTaskApp = taskNode.getTaskApp();
		setRegisteredAppName(singleTaskApp.getName());
		if (singleTaskApp.hasArguments()) {
			for (ArgumentNode argumentNode : singleTaskApp.getArguments()) {
				properties.put(argumentNode.getName(), argumentNode.getValue());
			}
		}
	}
	properties.put(SPRING_CLOUD_TASK_NAME, this.taskName);
	this.appDefinition = new AppDefinition(this.taskName, properties);
}
 
源代码8 项目: rice   文件: PeopleFlowBo.java
/**
 * Updates the values in the attribute values map from the attribute bos and updates the members.
 */
@PostLoad
protected void postLoad() {
    this.attributeValues = new HashMap<String, String>();
    for (PeopleFlowAttributeBo attributeBo: attributeBos) {
        this.attributeValues.put(attributeBo.getAttributeDefinition().getName(), attributeBo.getValue());
    }
    for (PeopleFlowMemberBo member: members) {
        if (member.getMemberName() == null) {
            member.updateRelatedObject();
        }
        for (PeopleFlowDelegateBo delegate: member.getDelegates()) {
            if (delegate.getMemberName() == null) {
                delegate.updateRelatedObject();
            }
        }
    }
}
 
源代码9 项目: spring-cloud-skipper   文件: Release.java
@PostLoad
public void afterLoad() {
	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	try {
		this.pkg = mapper.readValue(this.pkgJsonString, Package.class);
		this.configValues = new ConfigValues();
		if (this.configValuesString != null && StringUtils.hasText(configValuesString)) {
			this.configValues.setRaw(this.configValuesString);
		}
	}
	catch (IOException e) {
		throw new SkipperException("Error processing config values", e);
	}
}
 
源代码10 项目: griffin   文件: AbstractJob.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(predicateConfig)) {
        this.configMap = JsonUtil.toEntity(predicateConfig,
            new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码11 项目: griffin   文件: SegmentPredicate.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(config)) {
        this.configMap = JsonUtil.toEntity(config,
            new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码12 项目: griffin   文件: DataSource.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(checkpoint)) {
        this.checkpointMap = JsonUtil.toEntity(
            checkpoint, new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码13 项目: griffin   文件: Measure.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(sinks)) {
        this.sinksList = JsonUtil.toEntity(sinks, new TypeReference<List<String>>() {
        });
    }
}
 
源代码14 项目: griffin   文件: StreamingPreProcess.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(details)) {
        this.detailsMap = JsonUtil.toEntity(details,
            new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码15 项目: griffin   文件: Rule.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(details)) {
        this.detailsMap = JsonUtil.toEntity(
            details, new TypeReference<Map<String, Object>>() {
            });
    }
    if (!StringUtils.isEmpty(out)) {
        this.outList = JsonUtil.toEntity(
            out, new TypeReference<List<Map<String, Object>>>() {
            });
    }
}
 
源代码16 项目: griffin   文件: DataConnector.java
@PostLoad
public void load() throws IOException {
    if (!StringUtils.isEmpty(config)) {
        this.configMap = JsonUtil.toEntity(config,
            new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码17 项目: griffin   文件: GriffinMeasure.java
@PostLoad
public void load() throws IOException {
    super.load();
    if (!StringUtils.isEmpty(ruleDescription)) {
        this.ruleDescriptionMap = JsonUtil.toEntity(ruleDescription,
            new TypeReference<Map<String, Object>>() {
            });
    }
}
 
源代码18 项目: lams   文件: ACLEntryImpl.java
/**
 * <p>
 * Method called by the JPA layer after loading the persisted object.
 * </p>
 */
@PostLoad
@SuppressWarnings("unused")
private void loadState()
{
   if (this.permission != null)
      throw PicketBoxMessages.MESSAGES.aclEntryPermissionAlreadySet();
   this.permission = new CompositeACLPermission(this.bitMask);
}
 
源代码19 项目: monolith   文件: SectionAllocation.java
/**
 * Post-load callback method initializes the allocation table if it not populated already
 * for the entity
 */
@PostLoad
void initialize() {
	if (this.allocated == null) {
		this.allocated = new long[this.section.getNumberOfRows()][this.section.getRowCapacity()];
        for (long[] seatStates : allocated) {
            Arrays.fill(seatStates, 0l);
        }
    }
}
 
源代码20 项目: monolith   文件: SectionAllocation.java
/**
 * Post-load callback method initializes the allocation table if it not populated already
 * for the entity
 */
@PostLoad
void initialize() {
	if (this.allocated == null) {
		this.allocated = new long[this.section.getNumberOfRows()][this.section.getRowCapacity()];
        for (long[] seatStates : allocated) {
            Arrays.fill(seatStates, 0l);
        }
    }
}
 
源代码21 项目: monolith   文件: SectionAllocation.java
/**
 * Post-load callback method initializes the allocation table if it not populated already
 * for the entity
 */
@PostLoad
void initialize() {
	if (this.allocated == null) {
		this.allocated = new long[this.section.getNumberOfRows()][this.section.getRowCapacity()];
        for (long[] seatStates : allocated) {
            Arrays.fill(seatStates, 0l);
        }
    }
}
 
@PostLoad
@PostPersist
public void inject(Object object) {
    AutowireCapableBeanFactory beanFactory = get().getBeanFactory();
    if(beanFactory == null) {
        LOG.warn("Bean Factory not set! Depdendencies will not be injected into: '{}'", object);
        return;
    }
    LOG.debug("Injecting dependencies into entity: '{}'.", object);
    beanFactory.autowireBean(object);
}
 
源代码23 项目: nomulus   文件: Address.java
/**
 * Sets {@link #street} after loading the entity from Cloud SQL.
 *
 * <p>This callback method is used by Hibernate to set {@link #street} field as it is not
 * persisted in Cloud SQL. We are doing this because the street list field is exposed by Address
 * class and is used everywhere in our code base. Also, setting/reading a list of strings is more
 * convenient.
 */
@PostLoad
void postLoad() {
  street =
      streetLine1 == null
          ? null
          : Stream.of(streetLine1, streetLine2, streetLine3)
              .filter(Objects::nonNull)
              .collect(toImmutableList());
}
 
源代码24 项目: nomulus   文件: JodaMoneyConverterTest.java
@PostLoad
void setCurrencyScale() {
  moneyMap
      .entrySet()
      .forEach(
          entry -> {
            Money money = entry.getValue();
            if (!money.toBigMoney().isCurrencyScale()) {
              CurrencyUnit currency = money.getCurrencyUnit();
              BigDecimal amount = money.getAmount().setScale(currency.getDecimalPlaces());
              entry.setValue(Money.of(currency, amount));
            }
          });
}
 
源代码25 项目: che   文件: AbstractPermissions.java
@PostLoad
private void postLoad() {
  if (userId == null) {
    userIdHolder = "*";
  } else {
    userIdHolder = userId;
  }
}
 
源代码26 项目: che   文件: ProjectConfigImpl.java
@PostLoad
@PostUpdate
@PostPersist
private void postLoadAttributes() {
  if (dbAttributes != null) {
    attributes =
        dbAttributes.values().stream().collect(toMap(attr -> attr.name, attr -> attr.values));
  }
}
 
源代码27 项目: sakai   文件: Criterion.java
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Rubric rubric = getRubric();
    if (rubric != null && rubric.getMetadata().isShared()) {
        getMetadata().setShared(true);
    }
}
 
源代码28 项目: sakai   文件: Rubric.java
@PostLoad
@PostUpdate
public void determineLockStatus() {
    if (getToolItemAssociations() != null && getToolItemAssociations().size() > 0) {
        for(ToolItemRubricAssociation tira : getToolItemAssociations()) {
            if(tira.getParameters() == null) {
                getMetadata().setLocked(true);
            } else if(!tira.getParameters().containsKey(RubricsConstants.RBCS_SOFT_DELETED) || !tira.getParameters().get(RubricsConstants.RBCS_SOFT_DELETED)) {
                getMetadata().setLocked(true);
                break;
            }
        }
    }
}
 
源代码29 项目: sakai   文件: Rating.java
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Criterion criterion = getCriterion();
    if (criterion != null) {
        Rubric rubric = criterion.getRubric();
        if (rubric != null && rubric.getMetadata().isShared()) {
            getMetadata().setShared(true);
        }
    }
}
 
@PostLoad
public void handleDelta(final Object entity) {
  SalesOrderHeader so = (SalesOrderHeader) entity;

  if(so == null || so.getCreationDate() == null) {
    return;
  } else if (so.getCreationDate().getTime().getTime() < ODataJPATombstoneContext.getDeltaTokenUTCTimeStamp()) {
    return;
  } else {
    addToDelta(entity, ENTITY_NAME);
  }
}
 
 类所在包
 同包方法