Package org.springframework.data.mapping.model

Examples of org.springframework.data.mapping.model.MappingException


        String relationshipTypeAsString = relationshipProperties.getRelationshipType();

        if ( relationshipTypeAsString == null )
        {
            throw new MappingException( "Could not determine relationship-type for " + persistentEntity.getName() );
        }

        return DynamicRelationshipType.withName( relationshipTypeAsString );
    }
View Full Code Here


        super.verify();
        doWithProperties(new PropertyHandler<Neo4jPersistentProperty>() {
            Neo4jPersistentProperty unique = null;
            public void doWithPersistentProperty(Neo4jPersistentProperty property) {
                if (property.isUnique()) {
                    if (unique!=null) throw new MappingException("Duplicate unique property " + qualifiedPropertyName(property)+ ", " + qualifiedPropertyName(uniqueProperty) + " has already been defined. Only one unique property is allowed per type");
                    unique = property;
                }
            }
        });
        if (isManaged() || getType().isInterface()) {
            return;
        }
        final Neo4jPersistentProperty idProperty = getIdProperty();
        if (idProperty == null) throw new MappingException("No id property in " + this);
        if (idProperty.getType().isPrimitive()) throw new MappingException("The type of the id-property in " + qualifiedPropertyName(idProperty)+" must not be a primitive type but an object type like java.lang.Long");
    }
View Full Code Here

            return ((Node) state).getId();
        }
        if (isRelationshipEntity()) {
            return ((Relationship)state).getId();
        }
        throw new MappingException("Entity has to be annotated with @NodeEntity or @RelationshipEntity"+this);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public Object getPersistentId(Object entity) {
        final Neo4jPersistentProperty idProperty = getIdProperty();
        if (idProperty==null) throw new MappingException("No field annotated with @GraphId found in "+ getEntityName());
        return idProperty.getValue(entity, idProperty.getMappingPolicy());
    }
View Full Code Here

    private <R> Object getProperty(BeanWrapper<R> wrapper, Neo4jPersistentProperty property) {
        try {
            return wrapper.getProperty(property);
        } catch (Exception e) {
            throw new MappingException("Error retrieving property " + property.getName() + " from " + wrapper.getBean(), e);
        }
    }
View Full Code Here

    public <R> void setProperty(BeanWrapper<?> wrapper, Neo4jPersistentProperty property, Object value) {
        try {
            wrapper.setProperty(property,value);
        } catch (Exception e) {
            throw new MappingException("Setting property " + property.getName() + " to " + value + " on " + wrapper.getBean(), e);
        }
    }
View Full Code Here

    private <R> Object getProperty(BeanWrapper<R> wrapper, Neo4jPersistentProperty property) {
        try {
            return wrapper.getProperty(property);
        } catch (Exception e) {
            throw new MappingException("Error retrieving property " + property.getName() + " from " + wrapper.getBean(), e);
        }
    }
View Full Code Here

                typeInformation,
                annotation.elementClass() != Object.class ? ClassTypeInformation.from(annotation.elementClass()) : null,
                ctx
        );
        if (relationshipInfo.isRelatedToVia()) {
            throw new MappingException("Relationship field with NodeEntity "+relationshipInfo.getTargetEntity().getType()+" annotated with @RelatedTo");
        }
        return relationshipInfo;
    }
View Full Code Here

                annotation.direction(),
                typeInformation,
                elementClass,
                ctx
        );
        if (relationshipInfo.isRelatedTo()) throw new MappingException("Relationship field with RelationshipEntity "+relationshipInfo.getTargetEntity().getType()+" annotated with @RelatedToVia");
        return relationshipInfo;
    }
View Full Code Here

    private static String relationshipType(RelatedToVia annotation, TypeInformation<?> typeInformation) {
        if (!annotation.type().isEmpty()) return annotation.type();
        final TypeInformation<?> relationshipEntityType = elementClass(annotation, typeInformation);
        final RelationshipEntity relationshipEntity = relationshipEntityType.getType().getAnnotation(RelationshipEntity.class);
        if (relationshipEntity==null) {
            throw new MappingException(typeInformation.getType()+" is no RelationshipEntity");
        }
        if (relationshipEntity.type()==null || relationshipEntity.type().isEmpty()) {
            throw new MappingException("Relationship entity must have a default type");
        }
        return relationshipEntity.type();
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.mapping.model.MappingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.