}
Object entity = context.unmarshalEntity(type, mediaType(headers.getAcceptableMediaTypes()), in);
// maintain idempotence on PUT by disallowing sequencing
AbstractDirectMapping sequenceMapping = descriptor.getObjectBuilder().getSequenceMapping();
if (sequenceMapping != null) {
Object value = sequenceMapping.getAttributeAccessor().getAttributeValueFromObject(entity);
if (descriptor.getObjectBuilder().isPrimaryKeyComponentInvalid(value, descriptor.getPrimaryKeyFields().indexOf(descriptor.getSequenceNumberField()))
|| descriptor.getSequence().shouldAlwaysOverrideExistingValue()) {
JPARSLogger.error("jpars_put_not_idempotent", new Object[] { type, persistenceUnit });
throw JPARSException.entityIsNotIdempotent(type, persistenceUnit);
}
}
// maintain idempotence on PUT by disallowing sequencing in relationships
List<DatabaseMapping> mappings = descriptor.getMappings();
if ((mappings != null) && (!mappings.isEmpty())) {
for (DatabaseMapping mapping : mappings) {
if (mapping instanceof ForeignReferenceMapping) {
ForeignReferenceMapping fkMapping = (ForeignReferenceMapping) mapping;
if ((fkMapping.isCascadePersist()) || (fkMapping.isCascadeMerge())) {
ClassDescriptor referenceDescriptor = fkMapping.getReferenceDescriptor();
if (referenceDescriptor != null) {
if (referenceDescriptor instanceof RelationalDescriptor) {
RelationalDescriptor relDesc = (RelationalDescriptor) referenceDescriptor;
AbstractDirectMapping relSequenceMapping = relDesc.getObjectBuilder().getSequenceMapping();
if (relSequenceMapping != null) {
Object value = mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
if (value != null) {
if (value instanceof ValueHolder) {
ValueHolder holder = (ValueHolder) value;