Announcement Announcement Module
Collapse
No announcement yet.
help me with mapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • help me with mapping

    I have a table

    EA_MPF(
    SYS_MPF_ID,
    SYS_AUDIT_PROG_ID,
    SYS_FINDING_ID
    )
    EA_MPF_NON_LEAD_PROGS(
    SYS_MPF_ID,
    SYS_AUDIT_PROG_ID
    )

    EA_AUDIT_PROGRAM(
    SYS_AUDIT_PROG_ID,
    ...
    ..
    ..
    )

    here is the entity for EA_MPF table

    Code:
    
    @Entity
    @Table(name = "EA_MPF")
    public class MultiProgramFinding  {
    	
    	private Long  sysMPFId ;
    	
    	private EaAuditProgram  leadAuditProgram;
    	
    	private StgFinding  finding;
    	
    	private Set<EaAuditProgram>  nonLeadPrograms= new HashSet<EaAuditProgram>();
    
    	@Id
    	@GenericGenerator(name="ea_mpf_seq", strategy="sequence", parameters = {
                @Parameter(name = "sequence", value = "EA_MPF_SEQ"),
                @Parameter(name = "unsaved-value" , value = "null"),
                @Parameter(name = "allocationSize", value = "1")
        })
    	@GeneratedValue(generator="ea_mpf_seq")
    	@Column(name = "SYS_MPF_ID")
    	public Long getSysMPFId() {
    		return sysMPFId;
    	}
    
    	public void setSysMPFId(Long sysMPFId) {
    		this.sysMPFId = sysMPFId;
    	}
    	
    	
    	@OneToOne(optional=false,fetch=FetchType.LAZY)
    	@JoinColumn(name = "SYS_AUDIT_PROG_ID", nullable = false)
    	public EaAuditProgram getLeadAuditProgram() {
    		return leadAuditProgram;
    	}
    
    	public void setLeadAuditProgram(EaAuditProgram leadAuditProgram) {
    		this.leadAuditProgram = leadAuditProgram;
    	}
    
    	@OneToOne(optional=false,fetch=FetchType.LAZY)
    	@JoinColumn(name = "SYS_FINDING_ID", nullable = false)
    	public StgFinding getFinding() {
    		return finding;
    	}
    
    	public void setFinding(StgFinding finding) {
    		this.finding = finding;
    	}
    
    	@OneToMany(cascade=CascadeType.ALL)
    	@JoinTable(
    			name = "EA_MPF_NON_LEAD_PROGS",
    			joinColumns = {@JoinColumn(name = "SYS_MPF_ID")},
    			inverseJoinColumns = {@JoinColumn(name = "SYS_AUDIT_PROG_ID")}	
    	)
    	public Set<EaAuditProgram> getNonLeadPrograms() {
    		return nonLeadPrograms;
    	}
    
    	public void setNonLeadPrograms(Set<EaAuditProgram> nonLeadPrograms) {
    		this.nonLeadPrograms = nonLeadPrograms;
    	}
    	
    	
    }
    Entity for EA_AUDIT_PROGRAM is pojo with all getter and setter methods called EaAuditProgram


    as I per my understanding I have to map MultiProgramFinding in EaAuditProgram twice is that right or is there a better way to do the mapping please advice me ?
Working...
X