Search in sources :

Example 1 with PostLoad

use of jakarta.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(jakarta.persistence.PostLoad)

Example 2 with PostLoad

use of jakarta.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(jakarta.persistence.PostLoad)

Example 3 with PostLoad

use of jakarta.persistence.PostLoad in project tessera by ConsenSys.

the class StagingTransactionListener method onLoad.

@PostLoad
public void onLoad(StagingTransaction stagingTransaction) {
    LOGGER.debug("onLoad[{}]", stagingTransaction);
    final EncodedPayloadCodec encodedPayloadCodec = stagingTransaction.getEncodedPayloadCodec();
    final byte[] encodedPayloadData = stagingTransaction.getPayload();
    final PayloadEncoder payloadEncoder = PayloadEncoder.create(encodedPayloadCodec);
    final EncodedPayload encodedPayload = payloadEncoder.decode(encodedPayloadData);
    stagingTransaction.setEncodedPayload(encodedPayload);
}
Also used : PayloadEncoder(com.quorum.tessera.enclave.PayloadEncoder) EncodedPayload(com.quorum.tessera.enclave.EncodedPayload) EncodedPayloadCodec(com.quorum.tessera.enclave.EncodedPayloadCodec) PostLoad(jakarta.persistence.PostLoad)

Example 4 with PostLoad

use of jakarta.persistence.PostLoad in project tessera by ConsenSys.

the class EncryptedTransactionListener method onLoad.

@PostLoad
public void onLoad(EncryptedTransaction encryptedTransaction) {
    LOGGER.debug("onLoad[{}]", encryptedTransaction);
    final EncodedPayloadCodec encodedPayloadCodec = Optional.ofNullable(encryptedTransaction.getEncodedPayloadCodec()).orElse(EncodedPayloadCodec.LEGACY);
    final byte[] encodedPayloadData = encryptedTransaction.getEncodedPayload();
    final PayloadEncoder payloadEncoder = PayloadEncoder.create(encodedPayloadCodec);
    final EncodedPayload encodedPayload = payloadEncoder.decode(encodedPayloadData);
    encryptedTransaction.setPayload(encodedPayload);
    encryptedTransaction.setEncodedPayloadCodec(encodedPayloadCodec);
}
Also used : PayloadEncoder(com.quorum.tessera.enclave.PayloadEncoder) EncodedPayload(com.quorum.tessera.enclave.EncodedPayload) EncodedPayloadCodec(com.quorum.tessera.enclave.EncodedPayloadCodec) PostLoad(jakarta.persistence.PostLoad)

Aggregations

PostLoad (jakarta.persistence.PostLoad)4 EncodedPayload (com.quorum.tessera.enclave.EncodedPayload)2 EncodedPayloadCodec (com.quorum.tessera.enclave.EncodedPayloadCodec)2 PayloadEncoder (com.quorum.tessera.enclave.PayloadEncoder)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 GregorianCalendar (java.util.GregorianCalendar)2