Search in sources :

Example 1 with EmbeddableObject

use of org.apache.cayenne.EmbeddableObject in project cayenne by apache.

the class QualifierTranslator method getEmbeddableValueSnapshot.

private Map<String, Object> getEmbeddableValueSnapshot(Embeddable embeddable, Expression node, Expression parentNode) {
    int siblings = parentNode.getOperandCount();
    for (int i = 0; i < siblings; i++) {
        Object operand = parentNode.getOperand(i);
        if (node == operand) {
            continue;
        }
        if (operand instanceof EmbeddableObject) {
            EmbeddableObject embeddableObject = (EmbeddableObject) operand;
            Map<String, Object> snapshot = new HashMap<>(embeddable.getAttributes().size());
            embeddable.getAttributeMap().forEach((name, attr) -> snapshot.put(attr.getDbAttributeName(), embeddableObject.readPropertyDirectly(name)));
            return snapshot;
        }
    }
    throw new CayenneRuntimeException("Embeddable attribute ObjPath isn't matched with a valid value.");
}
Also used : EmbeddableObject(org.apache.cayenne.EmbeddableObject) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) EmbeddableObject(org.apache.cayenne.EmbeddableObject) ASTFullObject(org.apache.cayenne.exp.parser.ASTFullObject)

Aggregations

CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 EmbeddableObject (org.apache.cayenne.EmbeddableObject)1 ASTFullObject (org.apache.cayenne.exp.parser.ASTFullObject)1