users@glassfish.java.net

The class of the argument for the object comparison is incorrect.

From: <glassfish_at_javadesktop.org>
Date: Tue, 21 Aug 2007 00:13:39 PDT

I'm about to tear my hair out over this one, guys. Hope you can help me while I still have some left...

I have a many-to-one relationship between entities Access and Person: A person can have access to many services, but a service access record is applicable for one person only.

Using JPA, I have mapped the relationships using XML, as shown here: http://www.bluebricks.no/web/bbwebno.nsf/(files)/java.net/$file/orm.xml.txt
Code for the Person entity: http://www.bluebricks.no/web/bbwebno.nsf/(files)/java.net/$file/Person.java.txt
Code for the Access entity: http://www.bluebricks.no/web/bbwebno.nsf/(files)/java.net/$file/Access.java.txt
Full stacktrace: http://www.bluebricks.no/web/bbwebno.nsf/(files)/java.net/$file/stacktrace.txt

When I'm trying to fetch an access record from the database using a session bean, I get the following error:
Exception [TOPLINK-6078] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The class of the argument for the object comparison is incorrect.
Expression: [
Base com.bluebricks.net.entity.Access]
Mapping: [oracle.toplink.essentials.mappings.OneToOneMapping[person]]
Argument: [2 983]
Query: ReportQuery(com.bluebricks.net.entity.Access)

I try fetching the record by creating a query with the EntityManager, using the following JPQL:
SELECT x FROM Access x WHERE x.person=2983 AND x.service=12

Both the person and the service columns in the bb_access table are integer

If I try the following SQL query by hand to the database, the query succeeds:
SELECT * FROM bb_core.bb_access WHERE person=2983 AND service=12

This is the bean method:

public <T> T findRecord( Class<T> entityClass, String strQuery ) throws DatabaseConnectionException {

         try {
                Query query = getEntityManager().createQuery( strQuery );
                return entityClass.cast( query.getSingleResult( ) );
         } catch (NoResultException noResult) {
                 throw new DatabaseConnectionException( noResult.getMessage(), DatabaseConnectionException.RECORD_NOT_FOUND_ERROR );
         } catch (EntityNotFoundException notFound) {
                 throw new DatabaseConnectionException( notFound.getMessage(), DatabaseConnectionException.RECORD_NOT_FOUND_ERROR );
         } catch (NonUniqueResultException nonUnique) {
                 throw new DatabaseConnectionException( nonUnique.getMessage(), DatabaseConnectionException.RECORD_NOT_FOUND_ERROR );
            } // try
} // findRecord

The same method is used for all other entities as well, working as a charm. It is only when using the Access class I get an error, and I'm unable to see why.

Hopefully, some of you seeing this with "fresh eyes" will see something I can't.

Regards
Marius
[Message sent by forum member 'mariusw' (mariusw)]

http://forums.java.net/jive/thread.jspa?messageID=231745