コード例 #1
0
  @Override
  public void verify() {
    super.verify();
    doWithProperties(
        new PropertyHandler<Neo4jPersistentProperty>() {
          Neo4jPersistentProperty unique = null;

          public void doWithPersistentProperty(Neo4jPersistentProperty persistentProperty) {
            if (persistentProperty.isUnique()) {
              if (unique != null)
                throw new MappingException(
                    "Duplicate unique property "
                        + persistentProperty.getName()
                        + ", "
                        + unique.getName()
                        + " has already been defined. Only one unique property is allowed per type");
              unique = persistentProperty;
            }
          }
        });
    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 "
              + idProperty
              + " must not be a primitive type but an object type like java.lang.Long");
  }