16 Nisan 2018 Pazartesi

NaturalIdLoadAccess Arayüzü

load metodu
Şöyle yaparız.
public AddressKeyEntity getAddressKeyEntity(AddressKeyEntity addressKey) {
  AddressKeyEntity item = session.byNaturalId(AddressKeyEntity.class)
    .using("address", addressKey.getAddress())
    .using("city", addressKey.getCity())
    .using("state", addressKey.getState())
    .using("zip", addressKey.getZip())
    .with(LockOptions.UPGRADE.setTimeOut(LockOptions.WAIT_FOREVER))
    .load();
  if(item != null) {
    return item;
  } else {
    sessionFactory.getCurrentSession().persist(addressKey);
    return addressKey;
  }
}

Hiç yorum yok:

Yorum Gönder