I am new to Android development in general, and I have not even used greenDAO. But, having spent a lot of time on my generator class (where I model my entities), I was finally able to create something similar to the example provided in GitHub.
import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;
public class simbalDAOgen {
public static void main(String[] args) throws Exception {
Schema schema = new Schema(1, "com.bkp.simbal");
addCBTrans(schema);
new DaoGenerator().generateAll(schema, "../Simbal/src-gen", "../Simbal/src-test");
}
private static void addCBTrans(Schema schema){
Entity checkbook = schema.addEntity("Checkbook");
checkbook.addIdProperty();
checkbook.addStringProperty("name").notNull();
checkbook.addDateProperty("dateModified");
checkbook.addStringProperty("balance");
Entity transaction = schema.addEntity("Transaction");
transaction.setTableName("TRANS");
transaction.addIdProperty();
transaction.addStringProperty("name");
transaction.addStringProperty("category");
Property transDate = transaction.addDateProperty("date").getProperty();
transaction.addStringProperty("amount");
transaction.addStringProperty("notes");
Property cbName = transaction.addStringProperty("cb").notNull().getProperty();
ToMany cbToTrans = checkbook.addToMany(transaction, cbName);
cbToTrans.setName("Transactions");
cbToTrans.orderAsc(transDate);
}
}
Then I ran the code as a java application to create my DAO files, as described in the greenDAO documentation. The files were successfully generated, however I got this line in the console in Eclipse:
Warning to-one property type does not match target key type: ToMany 'Transactions' from Checkbook to Transaction
, , . , " ", " ", . ( , .)
? , , -, !