You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by David Minor <da...@gmail.com> on 2008/10/04 01:24:50 UTC

Data cache weirdness

If I have the data cache turned on, the map key for the collection
below seems to be of the wrong type (org.apache.openjpa.util.LongId
instead of Catalog). Attempting to iterate through the keySet throws a
ClassCastException to that effect. If I do an explicit cast to LongId
and call getId, it appears to have the IDs of the Catalogs that I'm
expecting to be there.

When I turn the cache off it works fine.


The mapped collection:

@OneToMany(targetEntity = CatalogProductPriceImpl.class, cascade = {
CascadeType.ALL }, fetch=FetchType.EAGER)
@MapKey(name = "catalog")
@ElementJoinColumn(name = "PRODUCT_UID")
@ElementDependent
@ElementForeignKey
public Map<Catalog, CatalogPrice> getCatalogPrices() {
	return catalogPrices;
}

The corresopnding field in CatalogProductPriceImpl is this:

@ManyToOne(optional = false, targetEntity = CatalogImpl.class, cascade
= { CascadeType.REFRESH })
@JoinColumn(name = "CATALOG_UID", nullable = false)
@ForeignKey
public Catalog getCatalog() {
	return catalog;
}



-- 
_____________
David Minor

Re: Data cache weirdness

Posted by Jeremy Bauer <te...@gmail.com>.
Hi David.

I'm am unable to reproduce the problem with the relationship
definitions provided.  Can you provide the entire entities?  If you
can provide a failing test case, that would be ideal.  Also, which
version of OpenJPA are you using?

-Jeremy