openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egoosen <egoos...@metropolitan.co.za>
Subject Re: OpenJPA 1.2.0 Bug on FetchType.EAGER
Date Mon, 22 Sep 2008 06:38:45 GMT

Hi Fay,

Here are the classes:

public class TblAmdctl extends BaseEntity {

//	Mapped Fields

@TableGenerator(name="tblAmdctlGenerator",schema="EBSTATUS",table="TBL_KEYGEN",pkColumnName="PRIMARY_KEY_COLUMN"
	
,valueColumnName="LAST_USED_ID",pkColumnValue="TBL_AMDCTL_ID",allocationSize=1)
		@Id
	
@GeneratedValue(strategy=GenerationType.TABLE,generator="tblAmdctlGenerator")
		@Column(name = "AMDCTL_ID",nullable=false)
		private Integer amdctlId;    

	@Version
	@Column(name = "VRS_NBR")
	private Integer vrsNbr;   

	@Basic
	@Column(name = "AMDSEQ_CDE",nullable=true) 
	private String amdseqCde;

	@Basic
	@Column(name = "DPLORD_NBR",nullable=true) 
	private Integer dplordNbr;

	@Basic
	@Column(name = "FND_CDE",nullable=true) 
	private String fndCde;

	@Basic
	@Column(name = "RSL_DTE",nullable=true) 
	@Temporal (TemporalType.DATE)
	private Date rslDte;


//	Mapped Relationships
	@OneToMany(mappedBy="tblAmdctl",fetch = FetchType.EAGER,cascade = {
CascadeType.PERSIST,CascadeType.MERGE})
	private Collection<TblAmddes> tblAmddess = new ArrayList<TblAmddes>();
	@ManyToOne(fetch = FetchType.LAZY,cascade = {
CascadeType.PERSIST,CascadeType.MERGE })
	@JoinColumns({@JoinColumn(name =
"FND_CDE",referencedColumnName="FND_CDE")})    
	@ForeignKey
	private TblFndmst tblFndmst;   
	public Integer getAmdctlId() {
		return getInteger(amdctlId);
	}
	public void setAmdctlId(Integer amdctlId) {
		this.amdctlId = amdctlId;
	}
	public Integer getVrsNbr() {
		return getInteger(vrsNbr);
	}
	public void setVrsNbr(Integer vrsNbr) {
		this.vrsNbr = vrsNbr;
	}

	public String getAmdseqCde() {
		return getString(amdseqCde);
	}
	public void setAmdseqCde(String amdseqCde) {
		this.amdseqCde = amdseqCde;
	}

	public Integer getDplordNbr() {
		return getInteger(dplordNbr);
	}
	public void setDplordNbr(Integer dplordNbr) {
		this.dplordNbr = dplordNbr;
	}
	public String getFndCde() {
		return fndCde;
	}
	public void setFndCde(String fndCde) {
		this.fndCde = fndCde;
	}
	public Date getRslDte() {
		return getDate(rslDte);
	}
	public void setRslDte(Date rslDte) {
		this.rslDte = rslDte;
	}
	public Collection<TblAmddes> getTblAmddess() {
		if (tblAmddess == null) {
			tblAmddess = new ArrayList<TblAmddes>();
		}
		return tblAmddess;
	}
	public void setTblAmddess(Collection<TblAmddes> tblAmddess) {
		this.tblAmddess = tblAmddess;
	}
	public void addTblAmddes(TblAmddes tblAmddes) {
		tblAmddes.setTblAmdctl(this);
		getTblAmddess().add(tblAmddes);
	}
	public void removeTblAmddes(TblAmddes tblAmddes) {
		tblAmddes.setTblAmdctl(null);
		getTblAmddess().remove(tblAmddes);
	}
	public void addAllTblAmddess(Collection<TblAmddes> tblAmddess){
		for (TblAmddes tblAmddes : tblAmddess) { 
			if (!getTblAmddess().contains(tblAmddes)){
				addTblAmddes(tblAmddes);
			}
		}
	}
	
	public TblFndmst getTblFndmst() {
		return tblFndmst;
	}
	
	public void setTblFndmst(TblFndmst tblFndmst) {
		this.tblFndmst = tblFndmst;
		if(tblFndmst!=null&&tblFndmst.getFndCde()!=null){
			setFndCde(tblFndmst.getFndCde());
		}	
	}
	
	protected void synchParentRelationships(){
		getAmdctlId();

		if (needsToSynch(getTblFndmst())) {
			setTblFndmst(getTblFndmst());
		}
	}
	
	protected void synchChildRelationships(){
		syncCollection(getTblAmddess());
	}
	protected  boolean isPKGenerated(){
		return true;	
	}
}

public class TblAmddes extends BaseEntity {

//	Mapped Fields

@TableGenerator(name="tblAmddesGenerator",schema="EBSTATUS",table="TBL_KEYGEN",pkColumnName="PRIMARY_KEY_COLUMN"
	
,valueColumnName="LAST_USED_ID",pkColumnValue="TBL_AMDDES_ID",allocationSize=1)
		@Id
	
@GeneratedValue(strategy=GenerationType.TABLE,generator="tblAmddesGenerator")
		@Column(name = "AMDDES_ID",nullable=false)
		private Integer amddesId;    

	@Version
	@Column(name = "VRS_NBR")
	private Integer vrsNbr;   

	@Basic
	@Column(name = "AMDCTL_ID",nullable=true) 
	private Integer amdctlId;

	@Basic
	@Column(name = "AMD_DES",nullable=true) 
	private String amdDes;

	@Basic
	@Column(name = "EFC_DTE",nullable=true) 
	@Temporal (TemporalType.DATE)
	private Date efcDte;


//	Mapped Relationships
	@ManyToOne(fetch = FetchType.LAZY,cascade = {
CascadeType.PERSIST,CascadeType.MERGE })
	@JoinColumns({@JoinColumn(name =
"AMDCTL_ID",referencedColumnName="AMDCTL_ID")})    
	@ForeignKey
	private TblAmdctl tblAmdctl;   
	public Integer getAmddesId() {
		return getInteger(amddesId);
	}
	public void setAmddesId(Integer amddesId) {
		this.amddesId = amddesId;
	}
	public Integer getVrsNbr() {
		return getInteger(vrsNbr);
	}
	public void setVrsNbr(Integer vrsNbr) {
		this.vrsNbr = vrsNbr;
	}

	public Integer getAmdctlId() {
		return getInteger(amdctlId);
	}
	public void setAmdctlId(Integer amdctlId) {
		this.amdctlId = amdctlId;
	}

	public String getAmdDes() {
		return getString(amdDes);
	}
	public void setAmdDes(String amdDes) {
		this.amdDes = amdDes;
	}

	public Date getEfcDte() {
		return getDate(efcDte);
	}
	public void setEfcDte(Date efcDte) {
		this.efcDte = efcDte;
	}
	public TblAmdctl getTblAmdctl() {
		return tblAmdctl;
	}
	public void setTblAmdctl(TblAmdctl tblAmdctl) {
		this.tblAmdctl = tblAmdctl;
		if(tblAmdctl!=null&&tblAmdctl.getAmdctlId()!=null){
			setAmdctlId(tblAmdctl.getAmdctlId());
		}	
	}
	protected void synchParentRelationships(){
		getAmddesId();

		if (needsToSynch(getTblAmdctl())) {
			setTblAmdctl(getTblAmdctl());
		}
	}
	protected void synchChildRelationships(){
	}
	protected  boolean isPKGenerated(){
		return true;	
	}
}


Fay Wang wrote:
> 
> Enrico,
> 
>    I have two findBy operations in my test case using the same em, and it
> works fine. According to your sql, you have FND_CDE in the where clause
> (see below):
> 
> SELECT t0.AMDCTL_ID, t0.VRS_NBR, t0.AMDSEQ_CDE, t0.DPLORD_NBR, t0.FND_CDE,
> t0.RSL_DTE FROM EBSTATUS.TBL_AMDCTL t0 WHERE t0.FND_CDE = ? 
> [params=(String) 0001001]
> 
> SELECT t0.AMDCTL_ID, t1.AMDDES_ID, t1.VRS_NBR, t1.AMD_DES, t1.AMDCTL_ID,
> t1.EFC_DTE FROM EBSTATUS.TBL_AMDCTL t0 INNER JOIN EBSTATUS.TBL_AMDDES t1
> ON t0.AMDCTL_ID = t1.AMDCTL_ID WHERE t0.FND_CDE = ? ORDER BY t0.AMDCTL_ID
> ASC [params=(String) 0000001]
> 
>    Is FND_CDE the primary key? Do you call: 
>       TblAmdctl ctl2 = em.find(TblAmdctl.class, 1);
> 
> It would be greatly appreciated if you could provide more information on
> the TblAmdctl.java and TblAmddes.java for us to debug the cache problem.
> Thanks!
> 
> -Fay   
> 

-- 
View this message in context: http://n2.nabble.com/OpenJPA-1.2.0-Bug-on-FetchType.EAGER-tp1100274p1108904.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message