コード例 #1
0
ファイル: JDBCBinder.java プロジェクト: sanctityQ/one
  private Property makeEntityProperty(
      String propertyName,
      boolean mutable,
      Table table,
      ForeignKey fk,
      ToOne value,
      boolean inverseProperty) {
    AssociationInfo fkei =
        inverseProperty
            ? revengStrategy.foreignKeyToInverseAssociationInfo(fk)
            : revengStrategy.foreignKeyToAssociationInfo(fk);

    String fetchMode = null;
    String cascade = null;
    boolean update = mutable;
    boolean insert = mutable;

    if (fkei != null) {
      cascade = fkei.getCascade();
      if (fkei.getUpdate() != null) {
        update = fkei.getUpdate().booleanValue();
      }
      if (fkei.getInsert() != null) {
        insert = fkei.getInsert().booleanValue();
      }

      fetchMode = fkei.getFetch();
    }

    if (FetchMode.JOIN.toString().equalsIgnoreCase(fetchMode)) {
      value.setFetchMode(FetchMode.JOIN);
    } else if (FetchMode.SELECT.toString().equalsIgnoreCase(fetchMode)) {
      value.setFetchMode(FetchMode.SELECT);
    } else {
      value.setFetchMode(FetchMode.SELECT);
    }

    return makeProperty(
        TableIdentifier.create(table),
        propertyName,
        value,
        insert,
        update,
        value.getFetchMode() != FetchMode.JOIN,
        cascade,
        null);
  }
コード例 #2
0
 private Iterator getSubPropertyIterator(PersistentClass pc, String reducedName) {
   Value value = pc.getRecursiveProperty(reducedName).getValue();
   Iterator parentPropIter;
   if (value instanceof Component) {
     Component comp = (Component) value;
     parentPropIter = comp.getPropertyIterator();
   } else if (value instanceof ToOne) {
     ToOne toOne = (ToOne) value;
     PersistentClass referencedPc = mappings.getClass(toOne.getReferencedEntityName());
     if (toOne.getReferencedPropertyName() != null) {
       try {
         parentPropIter =
             ((Component)
                     referencedPc
                         .getRecursiveProperty(toOne.getReferencedPropertyName())
                         .getValue())
                 .getPropertyIterator();
       } catch (ClassCastException e) {
         throw new MappingException(
             "dotted notation reference neither a component nor a many/one to one", e);
       }
     } else {
       try {
         if (referencedPc.getIdentifierMapper() == null) {
           parentPropIter =
               ((Component) referencedPc.getIdentifierProperty().getValue()).getPropertyIterator();
         } else {
           parentPropIter = referencedPc.getIdentifierMapper().getPropertyIterator();
         }
       } catch (ClassCastException e) {
         throw new MappingException(
             "dotted notation reference neither a component nor a many/one to one", e);
       }
     }
   } else {
     throw new MappingException(
         "dotted notation reference neither a component nor a many/one to one");
   }
   return parentPropIter;
 }