@Override protected ConsumerSPI internalSaveChangesTo(Consumer consumer) throws RegistrationException { ConsumerSPI consumerSPI = super.internalSaveChangesTo(consumer); ChromatticSession session = persister.getSession(); try { ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey()); cm.initFrom(consumer); persister.closeSession(true); } catch (Exception e) { persister.closeSession(false); throw new RegistrationException(e); } return consumerSPI; }
protected RegistrationSPI internalSaveChangesTo(Registration registration) throws RegistrationException { RegistrationSPI registrationSPI = super.internalSaveChangesTo(registration); ChromatticSession session = persister.getSession(); try { RegistrationMapping cm = session.findById(RegistrationMapping.class, registration.getPersistentKey()); cm.initFrom(registration); persister.closeSession(true); } catch (Exception e) { persister.closeSession(false); throw new RegistrationException(e); } return registrationSPI; }
@Override protected RegistrationSPI internalCreateRegistration( ConsumerSPI consumer, Map registrationProperties) throws RegistrationException { ChromatticSession session = persister.getSession(); RegistrationSPI registration = null; try { ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey()); RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null); registration = newRegistrationSPI(consumer, registrationProperties, rm.getPersistentKey()); rm.initFrom(registration); persister.closeSession(true); } catch (Exception e) { persister.closeSession(false); throw new RegistrationException(e); } return registration; }
private void remove(String id, Class clazz) { ChromatticSession session = persister.getSession(); session.remove(session.findById(clazz, id)); persister.closeSession(true); }