Search in sources :

Example 1 with PostLoad

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;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) PostLoad(javax.persistence.PostLoad)

Example 2 with PostLoad

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);
}
Also used : ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) PostLoad(javax.persistence.PostLoad)

Example 3 with PostLoad

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);
}
Also used : ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) PostLoad(javax.persistence.PostLoad)

Example 4 with PostLoad

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;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) PostLoad(javax.persistence.PostLoad)

Aggregations

PostLoad (javax.persistence.PostLoad)4 Calendar (java.util.Calendar)2 Date (java.util.Date)2 GregorianCalendar (java.util.GregorianCalendar)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2