Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ClassCastException when trying to access OneToOne object
ClassCastException when trying to access OneToOne object [message #1009227] Thu, 14 February 2013 17:58 Go to next message
jm collin is currently offline jm collinFriend
Messages: 7
Registered: February 2013
Junior Member
Hello there,

I'm trying to use EclipseLink 2.4.0 with MongoDB 2.2 on JBoss AS 7.1.1.
All works fine but I ran into a error trying to do something very simple.

I have 2 entities AttachmentRequest (A) and Account (B).
A have a relation with B declared like that :
@NoSql(dataType="ATTACHMENT_REQUEST", dataFormat=DataFormatType.MAPPED)
public class AttachmentRequest extends JPAMongoBaseToVoConvertible {
	private String id;
	// Relations
	// The emitter of this AttachmentRequest. Must be unique and present
	private Account emitterAccount=null;

@NoSql(dataType="account", dataFormat=DataFormatType.MAPPED)
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
public class Account extends JPAMongoBaseEntity {
	private String id;

I create successfully the A entity and link successfully with a B entity (verified directly in MongoDB).

Now I just to list all A having a = parameter.

I do a request like this :
TypedQuery<AttachmentRequest> q = em.createQuery("Select ar from AttachmentRequest ar join ar.emitterAccount em where", AttachmentRequest.class);
q.setParameter("emitterId", emitterId);
AttachmentRequest ar = q.getSingleResult();

The result is this exception :
[EL Warning]: 2013-02-14 18:37:11.454--UnitOfWork(1885572122)--Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.ClassCastException: org.eclipse.persistence.eis.mappings.EISOneToOneMapping cannot be cast to org.eclipse.persistence.mappings.OneToOneMapping].
Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.eis.mappings.EISOneToOneMapping cannot be cast to org.eclipse.persistence.mappings.OneToOneMapping
Query: ReadAllQuery(referenceClass=AttachmentRequest jpql="Select ar from AttachmentRequest ar join ar.emitterAccount em where")

Any help would be great appreciated because I'm blocked on this issue for 2 days.

Thank's in advance

Re: ClassCastException when trying to access OneToOne object [message #1009719 is a reply to message #1009227] Fri, 15 February 2013 15:29 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1109
Registered: July 2009
Senior Member
Joins are not supported for MongoDB as stated here:
you might try mapping the foreign key with a read-only basic mapping and accessing it in the query directly. Or adding a query key for the fk field as described here though I do not know how or if this will work with MongoDB.

Best Regards,

Previous Topic:How to clear cache?
Next Topic:Toplink to EclipseLink 2.4
Goto Forum:

Current Time: Wed Nov 25 02:27:04 GMT 2015

Powered by FUDForum. Page generated in 0.01735 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software