/**
* 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.properties == null) {
this.properties = new HashMap<>();
}
}
java类javax.persistence.PostLoad的实例源码
AbstractRegisteredService.java 文件源码
项目:springboot-shiro-cas-mybatis
阅读 38
收藏 0
点赞 0
评论 0
AbstractRegisteredService.java 文件源码
项目:springboot-shiro-cas-mybatis
阅读 37
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
CheckingEntityListener.java 文件源码
项目:os
阅读 40
收藏 0
点赞 0
评论 0
@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("数据验证失败!");
}
}
}
AbstractRegisteredService.java 文件源码
项目:cas-server-4.2.1
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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.properties == null) {
this.properties = new HashMap<>();
}
}
CheckingEntityListener.java 文件源码
项目:ha-db
阅读 42
收藏 0
点赞 0
评论 0
@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("数据验证失败!");
}
}
}
User.java 文件源码
项目:devwars.tv
阅读 39
收藏 0
点赞 0
评论 0
@PostLoad
public void postLoad() {
Session session = DatabaseManager.getSession();
if (this.getRanking() != null) {
this.rank = (Rank) session.createCriteria(Rank.class)
.add(Restrictions.le("xpRequired", this.getRanking().getXp().intValue()))
.addOrder(Order.desc("xpRequired"))
.setMaxResults(1)
.uniqueResult();
this.nextRank = (Rank) session.get(Rank.class, this.rank == null ? 1 : this.rank.getLevel() + 1);
}
session.close();
}
AbstractRegisteredService.java 文件源码
项目:cas4.1.9
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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();
}
if (this.properties == null) {
this.properties = new HashMap<>();
}
}
WarpDbCRUDAndCallbackTest.java 文件源码
项目:warpdb
阅读 33
收藏 0
点赞 0
评论 0
@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.save(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));
}
Product.java 文件源码
项目:sap_mobile_platform_espm_olingo_services
阅读 42
收藏 0
点赞 0
评论 0
@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();
}
}
PeopleFlowBo.java 文件源码
项目:kc-rice
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
}
PeopleFlowBo.java 文件源码
项目:rice
阅读 31
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
}
Release.java 文件源码
项目:spring-cloud-skipper
阅读 34
收藏 0
点赞 0
评论 0
@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) {
e.printStackTrace();
}
}
OidcRegisteredService.java 文件源码
项目:cas-5.1.0
阅读 29
收藏 0
点赞 0
评论 0
/**
* Initializes the registered service with default values
* for fields that are unspecified. Only triggered by JPA.
*/
@PostLoad
public void postLoad() {
if (this.scopes == null) {
this.scopes = new HashSet<>();
}
}
OAuthRegisteredService.java 文件源码
项目:cas-5.1.0
阅读 36
收藏 0
点赞 0
评论 0
/**
* Post load processing, once the service is located via JPA.
*/
@PostLoad
public void postLoad() {
if (this.supportedGrantTypes == null) {
this.supportedGrantTypes = new HashSet<>();
}
if (this.supportedResponseTypes == null) {
this.supportedResponseTypes = new HashSet<>();
}
}
AbstractRegisteredService.java 文件源码
项目:cas-5.1.0
阅读 37
收藏 0
点赞 0
评论 0
/**
* Initializes the registered service with default values
* for fields that are unspecified. Only triggered by JPA.
*
* @since 4.1
*/
@PostLoad
public 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.multifactorPolicy == null) {
this.multifactorPolicy = new DefaultRegisteredServiceMultifactorPolicy();
}
if (this.properties == null) {
this.properties = new HashMap<>();
}
if (this.attributeReleasePolicy == null) {
this.attributeReleasePolicy = new ReturnAllowedAttributeReleasePolicy();
}
}
AvatarUrlListener.java 文件源码
项目:xm-ms-entity
阅读 34
收藏 0
点赞 0
评论 0
@PostLoad
public void postLoad(XmEntity obj) {
String avatarUrl = obj.getAvatarUrl();
if (StringUtils.isNoneBlank(avatarUrl)) {
if (avatarUrl.matches(PATTERN_PART)) {
obj.setAvatarUrl(getPrefix() + avatarUrl);
} else {
obj.setAvatarUrl(null);
}
}
}
EntityClass.java 文件源码
项目:lams
阅读 44
收藏 0
点赞 0
评论 0
private void processDefaultJpaCallbacks(String instanceCallbackClassName, List<JpaCallbackClass> jpaCallbackClassList) {
ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName );
// Process superclass first if available and not excluded
if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) {
DotName superName = callbackClassInfo.superName();
if ( superName != null ) {
processDefaultJpaCallbacks( instanceCallbackClassName, jpaCallbackClassList );
}
}
String callbackClassName = callbackClassInfo.name().toString();
Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>();
createDefaultCallback(
PrePersist.class, PseudoJpaDotNames.DEFAULT_PRE_PERSIST, callbackClassName, callbacksByType
);
createDefaultCallback(
PreRemove.class, PseudoJpaDotNames.DEFAULT_PRE_REMOVE, callbackClassName, callbacksByType
);
createDefaultCallback(
PreUpdate.class, PseudoJpaDotNames.DEFAULT_PRE_UPDATE, callbackClassName, callbacksByType
);
createDefaultCallback(
PostLoad.class, PseudoJpaDotNames.DEFAULT_POST_LOAD, callbackClassName, callbacksByType
);
createDefaultCallback(
PostPersist.class, PseudoJpaDotNames.DEFAULT_POST_PERSIST, callbackClassName, callbacksByType
);
createDefaultCallback(
PostRemove.class, PseudoJpaDotNames.DEFAULT_POST_REMOVE, callbackClassName, callbacksByType
);
createDefaultCallback(
PostUpdate.class, PseudoJpaDotNames.DEFAULT_POST_UPDATE, callbackClassName, callbacksByType
);
if ( !callbacksByType.isEmpty() ) {
jpaCallbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, true ) );
}
}
EntityClass.java 文件源码
项目:lams
阅读 41
收藏 0
点赞 0
评论 0
private void processJpaCallbacks(String instanceCallbackClassName, boolean isListener, List<JpaCallbackClass> callbackClassList) {
ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName );
// Process superclass first if available and not excluded
if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) {
DotName superName = callbackClassInfo.superName();
if ( superName != null ) {
processJpaCallbacks(
instanceCallbackClassName,
isListener,
callbackClassList
);
}
}
Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>();
createCallback( PrePersist.class, JPADotNames.PRE_PERSIST, callbacksByType, callbackClassInfo, isListener );
createCallback( PreRemove.class, JPADotNames.PRE_REMOVE, callbacksByType, callbackClassInfo, isListener );
createCallback( PreUpdate.class, JPADotNames.PRE_UPDATE, callbacksByType, callbackClassInfo, isListener );
createCallback( PostLoad.class, JPADotNames.POST_LOAD, callbacksByType, callbackClassInfo, isListener );
createCallback( PostPersist.class, JPADotNames.POST_PERSIST, callbacksByType, callbackClassInfo, isListener );
createCallback( PostRemove.class, JPADotNames.POST_REMOVE, callbacksByType, callbackClassInfo, isListener );
createCallback( PostUpdate.class, JPADotNames.POST_UPDATE, callbacksByType, callbackClassInfo, isListener );
if ( !callbacksByType.isEmpty() ) {
callbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, isListener ) );
}
}
GegevenInOnderzoekListener.java 文件源码
项目:OperatieBRP
阅读 32
收藏 0
点赞 0
评论 0
/**
* Als dit een gegeven in onderzoek betreft dan moet de associatie van de entiteit naar dit
* gegeven in onderzoek worden aangemaakt.
*
* @param entity de geladen entiteit
*/
@PostLoad
public void postLoad(final Object entity) {
if (entity instanceof GegevenInOnderzoek) {
final GegevenInOnderzoek gegevenInOnderzoek = (GegevenInOnderzoek) entity;
if (gegevenInOnderzoek.getEntiteitOfVoorkomen() != null) {
Entiteit.convertToPojo(gegevenInOnderzoek.getEntiteitOfVoorkomen()).setGegevenInOnderzoek(gegevenInOnderzoek);
}
}
}
Admission.java 文件源码
项目:OSCAR-ConCert
阅读 30
收藏 0
点赞 0
评论 0
@PostLoad
public void postLoad() {
TeamName = team == null ? "" : team.getName();
ProgramName = program.getName();
ProgramType = program.getType();
}
ProviderPreference.java 文件源码
项目:OSCAR-ConCert
阅读 32
收藏 0
点赞 0
评论 0
@PostLoad
protected void hibernatePreFetchCollectionsFix() {
// forces eager fetching which can't be done normally as hibernate doesn't allow mulitple collection eager fetching
appointmentScreenForms.size();
appointmentScreenEForms.size();
appointmentScreenQuickLinks.size();
}
DatabaseManager.java 文件源码
项目:devwars.tv
阅读 44
收藏 0
点赞 0
评论 0
@Override
public void init() {
boolean testing = Boolean.parseBoolean(System.getProperty("testing"));
Configuration configuration = new Configuration();
configuration.configure("hibernate.cfg.xml");
configuration.setInterceptor(new HibernateInterceptor());
if (!testing) {
configuration.setProperty("hibernate.connection.username", Reference.getEnvironmentProperty("db.username"));
configuration.setProperty("hibernate.connection.password", Reference.getEnvironmentProperty("db.password"));
String url = "jdbc:mysql://" + Reference.getEnvironmentProperty("db.host") + ":" + Reference.getEnvironmentProperty("db.port") + "/devwars";
configuration.setProperty("hibernate.connection.url", url);
} else {
configuration.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
configuration.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:testdb");
configuration.setProperty("hibernate.connection.username", "sa");
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
}
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
EventListenerRegistry registry = ((SessionFactoryImpl) DatabaseManager.sessionFactory).getServiceRegistry().getService(EventListenerRegistry.class);
registry.getEventListenerGroup(EventType.POST_LOAD).appendListener(postLoadEvent ->
{
HibernateInterceptor.postLoadAny(postLoadEvent.getEntity());
HibernateInterceptor.invokeMethodWithAnnotation(postLoadEvent.getEntity(), PostLoad.class);
});
}
UserTeam.java 文件源码
项目:devwars.tv
阅读 37
收藏 0
点赞 0
评论 0
@PostLoad
public void setRanks() {
Session session = DatabaseManager.getSession();
this.rank = (Rank) session.createCriteria(Rank.class)
.add(Restrictions.le("xpRequired", this.getXp()))
.addOrder(Order.desc("xpRequired"))
.setMaxResults(1)
.uniqueResult();
this.nextRank = (Rank) session.get(Rank.class, this.rank == null ? 1 : this.rank.getLevel() + 1);
session.close();
}
User.java 文件源码
项目:devwars.tv
阅读 66
收藏 0
点赞 0
评论 0
@PostLoad
public void performCalculatedProperties() {
Session session = DatabaseManager.getSession();
Query gamesQuery = session.createQuery("select count(*) from Player p where p.user.id = :id");
gamesQuery.setInteger("id", id);
this.gamesPlayed = ((Long) DatabaseUtil.getFirstFromQuery(gamesQuery)).intValue();
Query gamesWonQuery = session.createQuery("select count(*) from Player p where p.user.id = :id and p.team.win = true and p.team.game.done = true");
gamesWonQuery.setInteger("id", id);
this.gamesWon = ((Long) DatabaseUtil.getFirstFromQuery(gamesWonQuery)).intValue();
Query gamesLostQuery = session.createQuery("select count(*) from Player p where p.user.id = :id and p.team.win = false and p.team.game.done = true");
gamesLostQuery.setInteger("id", id);
this.gamesLost = ((Long) DatabaseUtil.getFirstFromQuery(gamesLostQuery)).intValue();
if (this.getOwnedTeams() != null) {
Optional<UserTeam> ownedTeamOptional = this.getOwnedTeams().stream().findFirst();
if (ownedTeamOptional.isPresent()) {
this.setOwnedTeam(ownedTeamOptional.get());
}
}
session.close();
}
SpringEntityListener.java 文件源码
项目:example-ddd-with-spring-data-jpa
阅读 40
收藏 0
点赞 0
评论 0
@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);
}
DefaultEntityListener.java 文件源码
项目:jpasecurity
阅读 32
收藏 0
点赞 0
评论 0
@PostLoad
@SuppressWarnings("unused") // is used by reflection
private void privateTestMethod(Object entity) {
if (entity == null) {
throw new DefaultEntityListenerCalledException();
}
}
AbstractPermissions.java 文件源码
项目:che
阅读 34
收藏 0
点赞 0
评论 0
@PostLoad
private void postLoad() {
if (userId == null) {
userIdHolder = "*";
} else {
userIdHolder = userId;
}
}
ProjectConfigImpl.java 文件源码
项目:che
阅读 38
收藏 0
点赞 0
评论 0
@PostLoad
@PostUpdate
@PostPersist
private void postLoadAttributes() {
if (dbAttributes != null) {
attributes =
dbAttributes.values().stream().collect(toMap(attr -> attr.name, attr -> attr.values));
}
}
Criterion.java 文件源码
项目:sakai
阅读 37
收藏 0
点赞 0
评论 0
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
Rubric rubric = getRubric();
if (rubric != null && rubric.getMetadata().isShared()) {
getMetadata().setShared(true);
}
}
Rubric.java 文件源码
项目:sakai
阅读 30
收藏 0
点赞 0
评论 0
@PostLoad
@PostUpdate
public void determineLockStatus() {
if (getToolItemAssociations() != null && getToolItemAssociations().size() > 0) {
getMetadata().setLocked(true);
}
}