没有使用Select方法Dbflow定义Name $ Table?

时间:2017-05-15 20:48:49

标签: java android android-studio

我遇到Dbflow问题。我正在尝试创建一对多的关系,但在某些方法中存在错误。 See these picture. 我不知道问题的原因是什么。当我写这个名字时:Books $ Table里面的Condition.column方法 它显示为红色。

package com.example.hamoda.realtionship_dbflow;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.OneToMany;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.sql.language.Condition;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.raizlabs.android.dbflow.sql.language.Select;
import com.raizlabs.android.dbflow.structure.BaseModel;
import com.raizlabs.android.dbflow.sql.language.NameAlias;

import java.util.Collection;
import java.util.List;

@Table(database = MyDatabase.class)
public class Auther extends BaseModel{

    @Column
    @PrimaryKey
    int id;
    @Column
    String name;
    @Column
    int id_Auther;
    //private com.raizlabs.android.dbflow.sql.language.NameAlias Books$Table;
    public void setId(int id) {
        this.id = id;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Auther that = (Auther) o;
        return getName() != null ? getName().equals(that.getName()) : that.getName() == null;
    }

    @Override
    public int hashCode() {
        return getName() != null ? getName().hashCode() : 0;
    }
    List<Books>bookses;
    //  @OneToMany(methods = OneToMany.Method.ALL,variableName = "bookses")
    public List<Books>getBookses() {
        if (bookses == null) {
           bookses = new Select().from(Books.class).where(Condition.column(Books$Table).is(id)).queryList();
        }
        return bookses;
    }
}



    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}




    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.hamoda.realtionship_dbflow"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

def dbflow_version = "4.0.0-beta5"

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"

    // Adds a remote binary dependency only for the instrumented test APK.

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    testCompile 'junit:junit:4.12'
    // Testing-only dependencies


}

0 个答案:

没有答案