Search in sources :

Example 1 with EntityCompositeAlreadyExistsException

use of org.qi4j.api.unitofwork.EntityCompositeAlreadyExistsException in project qi4j-sdk by Qi4j.

the class EntityModel method newEntityState.

public EntityState newEntityState(EntityStoreUnitOfWork store, EntityReference identity) throws ConstraintViolationException, EntityStoreException {
    try {
        // New EntityState
        EntityState entityState = store.newEntityState(identity, this);
        // Set identity property
        PropertyDescriptor persistentPropertyDescriptor = state().propertyModelFor(IDENTITY_METHOD);
        entityState.setPropertyValue(persistentPropertyDescriptor.qualifiedName(), identity.identity());
        return entityState;
    } catch (EntityAlreadyExistsException e) {
        throw new EntityCompositeAlreadyExistsException(identity);
    } catch (EntityStoreException e) {
        throw new ConstructionException("Could not create new entity in store", e);
    }
}
Also used : PropertyDescriptor(org.qi4j.api.property.PropertyDescriptor) EntityAlreadyExistsException(org.qi4j.spi.entitystore.EntityAlreadyExistsException) EntityState(org.qi4j.spi.entity.EntityState) EntityStoreException(org.qi4j.spi.entitystore.EntityStoreException) ConstructionException(org.qi4j.api.common.ConstructionException) EntityCompositeAlreadyExistsException(org.qi4j.api.unitofwork.EntityCompositeAlreadyExistsException)

Aggregations

ConstructionException (org.qi4j.api.common.ConstructionException)1 PropertyDescriptor (org.qi4j.api.property.PropertyDescriptor)1 EntityCompositeAlreadyExistsException (org.qi4j.api.unitofwork.EntityCompositeAlreadyExistsException)1 EntityState (org.qi4j.spi.entity.EntityState)1 EntityAlreadyExistsException (org.qi4j.spi.entitystore.EntityAlreadyExistsException)1 EntityStoreException (org.qi4j.spi.entitystore.EntityStoreException)1