0

Eclipselink JPAの使用に問題があります

私は2つのエンティティを持っています:

public class Journal implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@NotBlank
@Size(max = 70)
@Column(name = "JOURNALNAME", unique = true, length = 70)
private String journalname;
@NotBlank
@Size(max = 70)
@Column(name = "PATHNAME", unique = true, length = 70)
private String pathname;
@Size(max = 70)
@Column(name = "ISSN", unique = true, length = 70)
private String issn;
@Size(max = 70)
@Column(name = "PRINCIPALNAME", length = 70)
private String principalname;
@Email
@Size(max = 70)
@Column(name = "PRINCIPALEMAIL", length = 70)
private String principalEmail;
@Column(name = "PRINCIPALPHONE", length = 70)
private String principalPhone;
@Size(max = 70)
@Column(name = "PRINCIPALFAX", length = 70)
private String principalFax;
@Size(max = 70)
@Column(name = "TECHNICALSUPPORT", length = 70)
private String technicalSupport;
@Email
@Size(max = 70)
@Column(name = "TECHNICALSUPPORTEMAIL", length = 70)
private String technicalSupportEmail;
@Size(max = 70)
@Column(name = "TECHNICALSUPPORTPHONE", length = 70)
private String technicalSupportPhone;
@Size(max = 200)
@Column(name = "EMAILSIGNATURE", length = 200)
private String emailSignature;
@Size(max = 4000)
@Column(name = "FOCUSSCOPE", length = 4000)
private String focusScope;
@Size(max = 4000)
@Column(name = "REVIEWPOLICY", length = 4000)
private String reviewPolicy;
@Size(max = 4000)
@Column(name = "REVIEWERGUIDELINES", length = 4000)
private String reviewerGuidelines;
@Size(max = 4000)
@Column(name = "COPYEDITORGUIDELINES", length = 4000)
private String copyeditorGuidelines;
@Size(max = 4000)
@Column(name = "PROOFREADERGUIDELINES", length = 4000)
private String proofreaderGuidelines;
@Size(max = 4000)
@Column(name = "LAYOUTEDITORGUIDELINES", length = 4000)
private String layouteditorGuidelines;
@Size(max = 4000)
@Column(name = "AUTHORGUIDELINES", length = 4000)
private String authorGuidelines;
@Column(name = "TYPICALREVIEWTIME")
private Integer typicalReviewTime;
@Size(max = 4000)
@Column(name = "DESCRIPTION", length = 4000)
private String description;
@Column(name = "HOSTED")
private boolean hosted;
@OneToMany(mappedBy = "journal", fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE})
private List<Submission> submissionList;
@OneToMany(mappedBy = "journal", cascade = {CascadeType.REMOVE})
private List<IntUserRoleJournal> intUserRoleJournalList;
@OneToMany(mappedBy = "journal")
private List<JournalSubmissionCheck> journalSubmissionCheckList;
@OneToMany(mappedBy = "journal", cascade = {CascadeType.REMOVE})
private List<Announcement> announcementList;
@OneToMany(mappedBy = "journal", cascade = {CascadeType.REMOVE})
private List<Form> formList;
@OneToMany(mappedBy = "journal", cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY)
private List<Issue> issueList;

と子:

public class Issue implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Size(max = 150)
@Column(name = "IDENTIFY", length = 150)
private String identify;
@Size(max = 70)
@Column(name = "TITLE", length = 70)
private String title;
@Column(name = "VOLUME", length = 5)
private String volume;
@Column(name = "NUMBER", length = 5)
private String number;
@Column(name = "YEAR", length = 4)
private String year;
@Column(name = "PUBLISH")
private boolean publish;
@Temporal(javax.persistence.TemporalType.DATE)
Date publishDate;
@Size(max = 7000)
@Column(name = "DESCRIPTION",columnDefinition = "text")
private String description;
@Size(max = 70)
@Column(name = "COVER", length = 70, unique = true)
private String cover;
@ManyToOne
private Journal journal;
@OneToMany(mappedBy = "issue", fetch = FetchType.LAZY,
cascade = {CascadeType.MERGE, CascadeType.REMOVE})
private List<Attachment> galleyList;

問題は、新しい問題を作成しようとするときです。ジャーナル、親として、以前に作成したすべての問題リストを常に取得します。fetchType.lazy を設定しても。積極的な動作を停止する唯一の方法は、親クラスの getter メソッドを削除することです。

 public String createIssue() {
    FacesMessage msg = null;
    FacesContext fc = FacesContext.getCurrentInstance();
    if (valueVolume == false
            && valueNumber == false
            && valueYear == false
            && valueTitle == false) {
        msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "Please spesify at least one issue identification", null);
    } else {
        try {
            issue.setJournal(journal);
            setIdentify();
            JournalRegistry.getCurrentInstance().createIssue(issue);
            journal.getIssueList().add(issue);
            JournalRegistry.getCurrentInstance().updateJournal(journal);
            msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Issue created", null);
            reset();
        } catch (EntityAccessorException ex) {
            Logger.getLogger(HeaIssueCreateB.class.getName()).log(Level.SEVERE, null, ex);
            msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                    "Occured error. "
                    + "Please try to refresh page or contact support", null);
        }
    }
    fc.addMessage(null, msg);
    return null;
}
4

0 に答える 0