use of javax.persistence.PostLoad in project hibernate-orm by hibernate.
the class Cat method calculateAge.
@PostLoad
public void calculateAge() {
Calendar birth = new GregorianCalendar();
birth.setTime(dateOfBirth);
Calendar now = new GregorianCalendar();
now.setTime(new Date());
int adjust = 0;
if (now.get(Calendar.DAY_OF_YEAR) - birth.get(Calendar.DAY_OF_YEAR) < 0) {
adjust = -1;
}
age = now.get(Calendar.YEAR) - birth.get(Calendar.YEAR) + adjust;
}
use of javax.persistence.PostLoad in project jgnash by ccavanaugh.
the class SecurityNode method postLoad.
@PostLoad
private void postLoad() {
lock = new ReentrantReadWriteLock(true);
// load the cache list
sortedHistoryNodeCache = new ArrayList<>(historyNodes);
// JPA will be naturally sorted, but XML files will not
Collections.sort(sortedHistoryNodeCache);
}
use of javax.persistence.PostLoad in project jgnash by ccavanaugh.
the class Account method postLoad.
@PostLoad
private void postLoad() {
transactionLock = new ReentrantReadWriteLock(true);
childLock = new ReentrantReadWriteLock(true);
securitiesLock = new ReentrantReadWriteLock(true);
attributesLock = new ReentrantReadWriteLock(true);
cachedSortedChildren = new ArrayList<>(children);
// JPA will be naturally sorted, but XML files will not
Collections.sort(cachedSortedChildren);
}
use of javax.persistence.PostLoad in project wildfly by wildfly.
the class Cat method calculateAge.
@PostLoad
public void calculateAge() {
Calendar birth = new GregorianCalendar();
birth.setTime(dateOfBirth);
Calendar now = new GregorianCalendar();
now.setTime(new Date());
int adjust = 0;
if (now.get(Calendar.DAY_OF_YEAR) - birth.get(Calendar.DAY_OF_YEAR) < 0) {
adjust = -1;
}
age = now.get(Calendar.YEAR) - birth.get(Calendar.YEAR) + adjust;
}
Aggregations