2013-08-22 33 views
1

下面是我的模式生成的代码,两个变量(storeIdForSurvey & questionIdForAnswer)模型中的类没有被自动生成(调查&问题),虽然他们是在汽车出现在生成的dao类(SurveyDao & QuestionDao)。greenDao发电机不发电在自动生成的类的某些变量

面向对象的域描述如下:用户有存储,存储有调查,调查有跟踪项目,调查有类别,类别有问题,问题有历史记录,问题有答案。

private static void addUser(Schema schema) { 

    //User 

    Entity user = schema.addEntity("User"); 

    user.addIdProperty(); 

    user.addStringProperty("districtId"); 

    user.addStringProperty("employeeId"); 

    user.addStringProperty("name"); 

    user.addStringProperty("sessionToken"); 

    user.addStringProperty("userId"); 



    //Store 

    Entity store = schema.addEntity("Store"); 

    // foreign key 

    Property userIdForStore = store.addLongProperty("userIdForStore").getProperty(); 

    store.addToOne(user, userIdForStore); 

    user.addToMany(store, userIdForStore); 



    store.addIdProperty(); 

    store.addStringProperty("storeId"); 

    store.addStringProperty("address"); 

    store.addStringProperty("city"); 

    store.addStringProperty("storeName"); 

    store.addStringProperty("state"); 

    store.addStringProperty("zip"); 

    store.addStringProperty("storeManagerName"); 

    store.addBooleanProperty("isSurveyHistoryAvailable");  





    //Survey 

    Entity survey = schema.addEntity("Survey"); 

    //foreign key 

    Property storeIdForSurvey = survey.addLongProperty("storeIdForSurvey").getProperty(); 

    survey.addToOne(store, storeIdForSurvey); // one store can have one survey at a time 

    store.addToOne(survey, storeIdForSurvey); 



    survey.addIdProperty(); 

    survey.addStringProperty("surveyId"); 

    survey.addStringProperty("dmSignImagePath"); 

    survey.addStringProperty("dmSignImageName"); 

    survey.addStringProperty("smSignImagePath"); 

    survey.addStringProperty("smSignImageName"); 

    survey.addStringProperty("startlatitude"); 

    survey.addStringProperty("startlongitude"); 

    survey.addStringProperty("submitLatitude"); 

    survey.addStringProperty("submitLongitude"); 

    survey.addStringProperty("acknowledgedBy"); 

    survey.addStringProperty("deliveredBy"); 

    survey.addStringProperty("name"); 

    survey.addStringProperty("createdBy"); 

    survey.addStringProperty("description"); 

    survey.addStringProperty("storeId"); 

    survey.addStringProperty("districtManager"); 



    survey.addDateProperty("startDate"); 

    survey.addDateProperty("submitDate"); 

    survey.addDateProperty("syncDate"); 

    survey.addDateProperty("createdDate"); 

    survey.addDateProperty("actionItemAssignDate"); 

    survey.addDateProperty("actionItemDueDate"); 

    survey.addDoubleProperty("score"); 





    //FolloupItems 

    Entity followupItem = schema.addEntity("FollowupItem"); 



    //foreign key 

    Property surveyIdForFollowupItem = followupItem.addLongProperty("surveyIdForFollowupItem").getProperty(); 

    followupItem.addToOne(survey, surveyIdForFollowupItem); 

    survey.addToMany(followupItem, surveyIdForFollowupItem); 



    followupItem.addIdProperty(); 

    followupItem.addStringProperty("assignedTo"); 

    followupItem.addStringProperty("comment"); 

    followupItem.addStringProperty("photoName"); 

    followupItem.addStringProperty("photoURL"); 

    followupItem.addDateProperty("assignedDate"); 

    followupItem.addDateProperty("dueDate"); 

    followupItem.addDateProperty("expeireDate"); 





    //Category 



    Entity category = schema.addEntity("Category"); 



    //foreign key 

    Property surveyIdForCategory = category.addLongProperty("surveyIdForCategory").getProperty(); 

    category.addToOne(survey, surveyIdForCategory); 

    survey.addToMany(category, surveyIdForCategory); 



    category.addIdProperty(); 

    category.addStringProperty("categoryId"); 

    category.addStringProperty("name"); 

    category.addStringProperty("weight"); 

    category.addStringProperty("surveyId"); 

    category.addDoubleProperty("totalScore"); 

    category.addIntProperty("sortOrder"); 

    category.addBooleanProperty("completionStatus"); 

    category.addBooleanProperty("hasActionItem"); 



    //Question 

     Entity question = schema.addEntity("Question"); 



     //foreign key 

     Property categoryIdForQuestion = question.addLongProperty("categoryIdForQuestion").getProperty(); 

     question.addToOne(category, categoryIdForQuestion); 

     category.addToMany(question, categoryIdForQuestion); 



     question.addIdProperty(); 

     question.addStringProperty("questionId"); 

     question.addDateProperty("startDate"); 

     question.addDateProperty("endDate"); 

     question.addStringProperty("statement"); 

     question.addStringProperty("type"); 

     question.addStringProperty("weight"); 

     question.addStringProperty("surveyCategoryName"); 

     question.addIntProperty("displayOrder"); 

     question.addBooleanProperty("naFlag"); 

     question.addBooleanProperty("isRequired"); 



     //Question History 

    Entity questionHistory = schema.addEntity("questionHistory"); 



    //foreign key 

    Property questionIdForQuestionHistory = questionHistory.addLongProperty("questionIdForQuestionHistory").getProperty(); 

    questionHistory.addToOne(store, questionIdForQuestionHistory); 

    question.addToMany(questionHistory, questionIdForQuestionHistory); 



    questionHistory.addIdProperty(); 

    questionHistory.addStringProperty("questionId"); 

    questionHistory.addStringProperty("secondLastHistory"); 

    questionHistory.addStringProperty("lastHistory"); 





     //Answer 

     Entity answer = schema.addEntity("Answer"); 



     //foreign key 

     Property questionIdForAnswer = answer.addLongProperty("questionIdForAnswer").getProperty(); 

     question.addToOne(answer, questionIdForAnswer); 

     answer.addToOne(question, questionIdForAnswer); 



     answer.addIdProperty(); 

     answer.addStringProperty("projectType"); 

     answer.addStringProperty("assignedTo"); 

     answer.addStringProperty("comment"); 

     answer.addStringProperty("photoUrl"); 

     answer.addStringProperty("photoNmae"); 

     answer.addStringProperty("selectedOption"); 

     answer.addDateProperty("assignedDate"); 

     answer.addDateProperty("dueDate"); 

     answer.addDateProperty("expireDate"); 

     answer.addDoubleProperty("score"); 



    } 

回答

2

请仔细阅读文档:

public ToOne addToOne(Entity target, Property fkProperty) 

添加一个到一个关系到使用给定的给定 外键属性(属于该实体)给定的目标实体。

这意味着以下说法正确的是:

Property storeIdForSurvey = survey.addLongProperty("storeIdForSurvey").getProperty(); 
survey.addToOne(store, storeIdForSurvey); 

,但下面的语句是不正确,因为物业storeIdForSurvey不是实体店的会员:

store.addToOne(survey, storeIdForSurvey); 

尝试使用此声明,而不是:

store.addToOneWithoutProperty("Survey", survey, "storeIdForSurvey"); 
+0

这工作,感谢很多 –

+0

另一件事情,让说调查有questionList,没有自动生成的函数,如setQuestionList(...),我怎么能更新questionList? –

+0

请为此写一个新问题,以便其他具有相同或相关问题的人员能够找到它,而不需要再次提问。请将新问题中的源代码缩短为相关内容(调查和问题列表以及这两者之间的关系)。我会在接下来的几天里寻找新的绿色问题。 – AlexS