diff --git a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/definition/ColumnDefinition.java b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/definition/ColumnDefinition.java index a944b8b3b..0970a45bf 100644 --- a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/definition/ColumnDefinition.java +++ b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/definition/ColumnDefinition.java @@ -383,6 +383,8 @@ public void writeLoadFromCursorDefinition(BaseTableDefinition tableDefinition, J // special case for model objects within class if (!fieldIsModelContainer && !isModelContainerAdapter && isModel) { + ColumnAccessModel columnAccessModel = new ColumnAccessModel(manager, this, isModelContainerAdapter); + for (ForeignKeyReference foreignKeyReference : foreignKeyReferences) { javaWriter.emitStatement(ModelUtils.getColumnIndex(foreignKeyReference.columnName())); } @@ -397,9 +399,14 @@ public void writeLoadFromCursorDefinition(BaseTableDefinition tableDefinition, J AdapterQueryBuilder adapterQueryBuilder = new AdapterQueryBuilder().appendVariable(false); adapterQueryBuilder.append(".") - .append(columnFieldName) - .appendSpaceSeparated("="); + .append(columnAccessModel.getSetterReferenceColumnFieldName()); + if (!columnAccessModel.isPrivate()) { + adapterQueryBuilder.appendSpaceSeparated("="); + } adapterQueryBuilder.append(rawConditionStatement); + if (columnAccessModel.isPrivate()) { + adapterQueryBuilder.append(")"); + } javaWriter.emitStatement(adapterQueryBuilder.getQuery()); javaWriter.endControlFlow(); diff --git a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ColumnAccessModel.java b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ColumnAccessModel.java index 9ee047cf4..f06e48ce1 100644 --- a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ColumnAccessModel.java +++ b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ColumnAccessModel.java @@ -190,7 +190,7 @@ public String getQuery(boolean useCastIfApplicable) { } else if (fieldIsAModelContainer) { contentValue.append(columnName) .append(".") - .appendGetValue(getReferencedColumnFieldName()); + .appendGetValue(referencedColumnFieldName); } else { if (isForeignKeyField) { ColumnAccessModel columnAccessModel = new ColumnAccessModel(parentColumnDefinition.getManager(), parentColumnDefinition, isModelContainerAdapter); diff --git a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ForeignKeyContainerModel.java b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ForeignKeyContainerModel.java index 1a7190ffc..a4294da95 100644 --- a/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ForeignKeyContainerModel.java +++ b/DBFlow-Compiler/src/main/java/com/raizlabs/android/dbflow/processor/model/writer/ForeignKeyContainerModel.java @@ -45,7 +45,7 @@ public void write(JavaWriter javaWriter) throws IOException { .appendCast(accessModel.castedClass) .append(modelContainerName) .append(".") - .appendGetValue(accessModel.getReferencedColumnFieldName()) + .appendGetValue(accessModel.referencedColumnFieldName) .append("))"); javaWriter.emitStatement(adapterQueryBuilder.getQuery());