openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: StrictIdentityValues Issues leading to !(x instanceof Long)
Date Wed, 15 Apr 2009 15:53:21 GMT

Try changing your keys from primitive long to java.lang.Long.

-Rick


I'm having some problems with the Property 'openjpa.Compatibility' and the Value StrictIdentityValues=false.We
are using IBM Websphere 6.1 incl. EJB3 Feature Pack (openJPA 1.0.4-SNAPSHOT) which by default
sets this value to 'true'. In the following Scenario, I get an exception which I do not understand,
as I can't find a problem with the types of the Id-Fields.

@Entity
@Table(name = "FREITEXT")
public class Freitext 
{
	@Id
	@Column(name = "FREITEXT_KEY")
	private long key;
	
	@Column(name = "PART_KEY")
	private long partKey;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PART_KEY")
	private Partner partner;
}

@Entity
@Table(name = "PARTNER", schema = "PART")
@NamedQuery(name = "getPartner", query = "SELECT p FROM Partner p where p.partKey = :partKey")
public class Partner 
{
	@Id
	@Column(name = "PART_KEY")
	private long partKey;

	@OneToMany(mappedBy = "partner", fetch = FetchType.LAZY)
	private List<Freitext> freitexte;
}

In case StrictIdentityValues is set 'true' (as default for the Websphere), this leads to the
following Exception when accessing parter.getFreitexte().

[15.04.09 10:43:45:577 CEST] 00000022 SystemErr     R Caused by: java.lang.ClassCastException:
!(x instanceof Long)
	at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:159)
	at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:192)
	at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:146)
	at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.load(RelationFieldStrategy.java:531)
	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:796)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:833)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:785)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:336)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:255)
	at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
	at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:844)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:802)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:724)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:776)
	at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:257)
	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2267)
	at org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:87)
	at org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldStrategy.java:76)
	at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:479)
	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:485)
	at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
	at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
	at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2886)
	at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2964)
	at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1463)
	at org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1448)
	at com.mbbank.model.Partner.pcGetfreitexte(Partner.java)
	at com.mbbank.model.Partner.getFreitexte(Partner.java:776)
	at com.mbbank.services.GetPersonHandler.createNotes(GetPersonHandler.java:366)

If I set it to 'false', it works out quite well. Is somebody able to bring some light in this
issue, preferably why it might be necessary to have StrictIdentityValues set 'false' and where
my mistake could be? Any ideas would be gladly welcome.

Sincerely,

Heiko Kopp


-- 
View this message in context: http://n2.nabble.com/StrictIdentityValues-Issues-leading-to-%21%28x-instanceof-Long%29-tp2637697p2639642.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message