コード例 #1
0
  @Override
  public void deleteByRelationType(IRelationType relationType) {
    // delete source reference pointing to relation type
    OSQLSynchQuery<ODocument> query =
        new OSQLSynchQuery<>("select * from Relation where relationType = " + relationType.getId());
    List<ODocument> result = db.command(query).execute();

    // remove relation and link
    for (ODocument document : result) {
      ODocument relationLink = getRelationLink(document, true);
      if (relationLink != null && db.load(relationLink.getIdentity()) != null)
        relationLink.delete();

      document.delete();
    }
  }
コード例 #2
0
  @Override
  public List<IRelation> findByRelationType(IRelationType relationType) {
    List<IRelation> list = new LinkedList<>();

    // no NPEs
    if (relationType == null) return list;

    initDb();

    // execute query
    OSQLSynchQuery<ODocument> query =
        new OSQLSynchQuery<>("select * from Relation where relationType = " + relationType.getId());
    List<ODocument> result = db.command(query).execute();

    // populate set
    for (ODocument document : result) list.add(convertToEntity(document));

    return list;
  }