@Override public void passivate() throws Exception { UnitOfWork uow = uowf.newUnitOfWork(); try { RootEntity root = rootEntity(); LOGGER.info("Existing RootEntity: " + root.identity().get()); } catch (NoSuchEntityException ex) { LOGGER.info("No RootEntity"); } uow.complete(); }
@Override public void activate() throws Exception { UnitOfWork uow = uowf.newUnitOfWork(); try { RootEntity root = rootEntity(); LOGGER.info("Will use RootEntity: " + root.identity().get()); } catch (NoSuchEntityException ex) { EntityBuilder<RootEntity> builder = uow.newEntityBuilder(RootEntity.class, RootEntity.IDENTITY); RootEntity root = builder.newInstance(); LOGGER.info("Created new RootEntity: " + root.identity().get()); } uow.complete(); }