整个实体实例作为参数或其id

时间:2014-06-29 10:22:09

标签: jpa

我想坚持实体InterviewFeedbackInterviewGuideApplication是其他实体。我应该作为参数传递整个实体实例(例如,Application),还是仅传递实体的id,然后通过其id进行查询以查找实例?将整个实体实例作为参数传递的问题是什么?

public void createInterview(Date interviewDate, Interviewer interviewer, InterviewGuide interviewGuide, Application application) {
        InterviewFeedback interviewFeedback = new InterviewFeedback();
        interviewFeedback.setInterviewer(interviewer);
        interviewFeedback.setInterviewDate(interviewDate);
        interviewFeedback.setInterviewGuide(interviewGuide);
        if (knowIfInterviewHasPhoneInterviewGuide(InterviewType.PHONE, application)) {
            interviewFeedback.setInterviewType(InterviewType.PHONE);

        } else {
            interviewFeedback.setInterviewType(InterviewType.PRESENCIAL);
        }
        interviewFeedback.setApplication(application);
        em.persist(interviewFeedback);

    }

0 个答案:

没有答案