2017-03-12 1 views
1

나는이 ORM을 배우기 시작 했으므로 어쩌면 내가 잘못한 것일 수도있다. 엔티티에서 OneToOne 관계를 작성하지만 greendao는 생성하지 않습니다. 외래 키에 대한 엔티티 생성자 인수를 쓰고 있다면 이것을 무시하고 이렇게 만듭니다. 따라서 테이블에는 속성과 열이 없습니다. 고맙습니다.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; 
} 

PublicDao :

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 
} 

답변

0

내 실수. 다른 필드를 추가하고 joinProperty에이를 써야합니다.

관련 문제