Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GreenDao不创建外键?_Java_Android_Sqlite_Foreign Keys_Greendao - Fatal编程技术网

Java GreenDao不创建外键?

Java GreenDao不创建外键?,java,android,sqlite,foreign-keys,greendao,Java,Android,Sqlite,Foreign Keys,Greendao,我刚刚开始学习这个ORM,所以可能我做错了什么。在实体中,我编写了OneToOne关系,但greendao没有生成它。如果我在为外键编写实体构造函数参数,它只会忽略这一点,并使其像这样。所以表中没有属性和列。多谢各位 公众: @Entity(active = true) public class Public { @Id(autoincrement = true) Long id; int publicId; @ToOne(joinProperty = "id") private Cate

我刚刚开始学习这个ORM,所以可能我做错了什么。在实体中,我编写了OneToOne关系,但greendao没有生成它。如果我在为外键编写实体构造函数参数,它只会忽略这一点,并使其像这样。所以表中没有属性和列。多谢各位

公众:

@Entity(active = true)
public class Public {

@Id(autoincrement = true)
Long id;

int publicId;

@ToOne(joinProperty = "id")
private Category category;  ...

@Generated(hash = 12945501)
public Public(Long id, int publicId) {
    this.id = id;
    this.publicId = publicId;
}
公共道:

public class PublicDao extends AbstractDao<Public, Long> {

public static final String TABLENAME = "PUBLIC";

/**
 * Properties of entity Public.<br/>
 * Can be used for QueryBuilder and for referencing column names.
 */
public static class Properties {
    public final static Property Id = new Property(0, Long.class, "id", true, "_id");
    public final static Property PublicId = new Property(1, int.class, "publicId", false, "PUBLIC_ID");
}    ...

/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
    String constraint = ifNotExists? "IF NOT EXISTS ": "";
    db.execSQL("CREATE TABLE " + constraint + "\"PUBLIC\" (" + //
            "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
            "\"PUBLIC_ID\" INTEGER NOT NULL );"); // 1: publicId
}

我的错误。我应该为它添加另一个字段,并将其写入joinProperty