帝国 只做网站地图,开发一亩地多少钱,成都外贸网站建设,图片素材的网站请尝试以下方法#xff1a;我认为它涵盖了你所有的设计要点.我试图在您的评论之间进行阅读,我认为您希望实现一个系统,您可以在其中捕获一些“规则”以供审核(我猜测,但示例可能是评论可以达到n在评论获得一定程度的质量之前,必须至少有m个顾客评论.如果确实如此,我创建了一个…请尝试以下方法我认为它涵盖了你所有的设计要点.我试图在您的评论之间进行阅读,我认为您希望实现一个系统,您可以在其中捕获一些“规则”以供审核(我猜测,但示例可能是评论可以达到n在评论获得一定程度的质量之前,必须至少有m个顾客评论.如果确实如此,我创建了一个ReviewTemplate类 ReviewTemplate将为您需要的每个值提供属性/列.这些属性/列在Review上重复使用多个行填充ReviewTemplate,然后在Course中创建一行并将其链接到一个ReviewTemplate当课程需要审核时,将ReviewTemplate中的字段复制到Review中在Java中,使用复制的值实现Review的业务规则 – 而不是ReviewTemplate上的值.为什么要复制这些值好吧,我敢打赌,在某些时候,用户想要编辑ReviewTemplate表.如果是这样,使用编辑过的ReviewTemplates对Review对象会发生什么 ReviewTemplate上的修改值是否会以某种方式使过去的评论失效并破坏您的业务逻辑不,因为您将规则值复制到Review,因此过去的评论不会更改.编辑具体问题的答案How do you see the duplicating? I can create an entity ReviewTemplate with the specified attributes. In this entity there will be a relationship with reviewlines and feedbackscores.我将每个ReviewTemplate视为包含特定“类型”Review的原型值,其中可能包含默认reviewLine(但可能没有意义)和默认feedbackScore.创建Review时,您将执行以下操作实例化Review并使用ReviewTemplate中的值填充根据需要实例化尽可能多的CustomerReview对象,将它们链接到相关的Customer对象(我从之前的评论中推断出这一步.在客户自愿选择审阅课程之前,省略此步骤也是有意义的)(如果适用)使用ReviewTemplate的默认值填充CustomerReview属性feedbackScore根据需要实例化CustomerReviewLine记录如果您遵循此方法,则无需在ReviewTemplate和CustomerReviewLines之间添加关系.When I e.g. state that customers 1 to 4 need to fill in the review 4 specific “objects” need to be created that will hold the information and also 4 sets of the needed reviewlines and feedbackscores need to be created so they all can hold the information.绝对.I just don’t know how to implement this is a JPA structure so the information is hold in the db … ?JPA允许您以多种方式解决问题,但最佳做法是手动创建数据库模式和Java类(例如,参见https://stackoverflow.com/a/2585763/1395668).因此,对于图中的每个实体,您需要编写SQL DDL语句以创建表,列,主键和外键,以及编写用entity注释表示的Java类.在类中,您还需要使用id注释id(主键)以及与OneToMany或ManyToOne的关系(注释中的其他参数也要设置).现在,在JPA方面,您可以执行以下操作ReviewTemplate template course.getReviewTemplate(); //assuming the variable courseReview review new Review();review.setCourse(course);review.setRuleOne(template.getRuleOne());// Copy other properties hereEntityManager em // get the entity manager hereem.persist(review);// Assume a set or list of customersfor (Customer customer : customers) {CustomerReview cr new CustomerReview();cr.setReview(review);cr.setCustomer(customer);cr.setFeedbackScore(template.getDefaultFeedbackScore());// set other CustomerReview properties hereem.persist(cr);// You can create CustomerReviewLine here as well如果在标准EJB会话Bean中编写,这将很好地进行交易,并且您将所有新记录提交到数据库中.编辑2补充问题(我假设第二条评论完全取代第一条评论)So when I create a reviewtemplate and I link it to a bunch of customers I write the template to the db and create a bunch of reviews based on the template but linked to the specific customer and with his own unique reviewlines and feedbackscores. Like I see it now the reviewline (more a question or discription) is the same for each review (of a template), it is only the score that changes between the customers我终于想到了解了ReviewLine.我认为这是客户输入包含CustomerReview的文本行的地方.我现在相信ReviewLine是一个特定的问题,客户被问及客户提供的反馈评分.根据这种理解,这是一个更新的ER /类图.请注意,有一些重大更改 – 还有几个表 ReviewLineTemplate提供了一个存储在ReviewTemplate上的模板问题的位置当实例化/插入评论(这是特定ReviewTemplate的副本)时,ReviewLineTemplates将复制为ReviewLines.复制操作允许两个重要功能在创建时,可以自定义Review及其ReviewLines,而不会影响ReviewTemplate或ReviewLineTemplate随着时间的推移,ReviewTemplate和ReviewLineTemplate可以更新,编辑和不断改进,而无需更改客户已经回答的问题.如果CustomerFeedbackScore直接链接到ReviewLineTemplate,那么编辑ReviewLineTemplate将改变客户已回答的问题,默默地使feedbackScore无效. FeedbackScore已移至ReviewLine和CustomerReview之间的联接表.请注意,此模型是完全非规范化的,这使得它更“正确”,但更难为其构建GUI.一个常见的’优化’可能是介绍ReviewTemplate和Review上的10个(比方说)列称为reviewLine1到reviewLine10.CustomerReview上的10个(比方说)列通过feedbackScore10调用feedbackScore1.删除ReviewTemplateLine,ReviewLine和CustomerReviewLine表这样做不规范化,可能会引入一系列其他问题.因人而异