有ExamPaper考卷类,对应EXAMPAPER表,有栏位 id name
Question题目类(放在题库中的题),对应QUESTION表,有栏位 id content type
ExamQuestion考题类(考卷上的题目),对应EXAMPAPER_QUESTION表,有栏位 id exampaper_id question_id score
题目分选择 填空 解答3个类型,我分别映射了ChoiceQuestion FillingQuestion ProcessQuestion 3个Question的子类,但我希望在ExamPaper类中取得此考卷所有的选择题或所有的填空题,该如何配置?或者是我的设计有问题,怎么修正?
[b]问题补充:[/b]
谢谢wangxin0072000的回答,但你没明白我的意思,ExamQuestion是ExamPaper和Question的中间类,体现了考卷和题目的关系,我想知道怎样使ExamQuestion能够表现出Question的分类,即Question的子类ChoiceQuestion FillingQuestion ProcessQuestion分别对应ExamQuestion的子类ChoiceExamQuestion FillingExamQuestion ProcessExamQuestion,因为我想在ExamPaper类中加入方法getChoiceQuestions(),返回的是考卷中所有选择题。
[b]问题补充:[/b]
嗯?意思是ExamPaper和Question的子类多对多关联,中间表为EXAMPAPER_QUESTION,因为我需要中间表的score 属性,所以再建一个ExamQuestion类与中间表对应,要从ExamPaper取出每题的得分,那么ExamPaper又要与ExamQuestion-对多关联,这样ExamPaper<-1---n->ExamQuestion<-m---1->Question,ExamPaper<-n---m->Question.是这样吗?这样配置不会有脏数据问题吗?
[b]问题补充:[/b]
可能是设计的问题吧,你能帮我想个解决办法么?需求如下:
随机从题库产生考卷,考卷明细包括题型 总分 总得分 每题分数 每题得分.
[b]问题补充:[/b]
对于maxwell的建议,那么如何配置以保证ExamQuestion和Question的type一一对应呢?
难道要每次都examQuestion.setType(“A”)?