Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Re: IndirectMap.containsKey leads to Exception because DISTINCT, on @Lob-Field (Reinhard Girstenbrei)

Hi Hans,
Oracle Database Server does not allow to use the DISTINCT clause if there is a select list item of data type LOB. You are using the batch reading which generates queries including a DISTINCT clause.
Now, as you have an attributed mapped to a LOB you run into this problem.
Your can resolve this problem by not using batch reading.

If you have access to "My Oracle Support" (formerly known as Metalink) you have access to the following enhancement request:

Bug 6646443 - ALLOW *BATCH* *READING* OF *LOB* COLUMNS IN ONETOMANY AND MANYTOMANY RELATIONSHIPS

I have not found an enhancement request for such feature on bugzilla yet.

You can open a new SR if you have a valid support contract to vote for this enhancement request or open an enhancement request at bugzilla.
https://bugs.eclipse.org/bugs/
Classification: RT
Product: EclipseLink
Component: Foundation

Greetings,
Reinhard

eclipselink-users-request@xxxxxxxxxxx wrote:
Send eclipselink-users mailing list submissions to
	eclipselink-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
	https://dev.eclipse.org/mailman/listinfo/eclipselink-users
or, via email, send a message with subject or body 'help' to
	eclipselink-users-request@xxxxxxxxxxx

You can reach the person managing the list at
	eclipselink-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of eclipselink-users digest..."


Today's Topics:

   1. Postgres arrays (Mike Traum)
   2. Re: Postgres arrays (Mike Traum)
   3. ReadAllQuery fetch all (Martin Janda)
   4. IndirectMap.containsKey leads to Exception because DISTINCT
      on @Lob-Field (Hans Harz)
   5. Re: ReadAllQuery fetch all (Tom Ware)
   6. Re: how can I reference a foreign key in ejbql	where
      condition? (James Sutherland)
   7. Re: How eclipselink handles Sequences? (James Sutherland)


----------------------------------------------------------------------

Message: 1
Date: Mon, 16 Nov 2009 09:31:00 -0800
From: Mike Traum <Mike.Traum@xxxxxxxx>
Subject: [eclipselink-users] Postgres arrays
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <4B018C54.502@xxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi,
I'm trying to get a mapping for postgres arrays working. I'm using a Converter and thus far (without a lot of testing), inserting an array seems to work fine. But, when reading that array, eclipselink (1.2) throws the following exception before we even get to the Converter:
java.lang.ClassCastException: [D cannot be cast to [Ljava.lang.Object;
at org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor.buildArrayObjectFromArray(ObjectRelationalDataTypeDescriptor.java:326)
...

The problem seems to be that eclipselink is attempting to cast java.sql.Array.getArray() to Object[], but postgres returns an array of primitives. This seems like an eclipselink bug, no? Any idea for a workaround?

Thanks,
Mike



------------------------------

Message: 2
Date: Mon, 16 Nov 2009 13:30:31 -0800
From: Mike Traum <Mike.Traum@xxxxxxxx>
Subject: [eclipselink-users] Re: Postgres arrays
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <4B01C477.1090207@xxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I seem to have worked out my issues. I upgraded the jdbc driver from postgresql-8.2-506.jdbc3.jar to postgresql-8.4-701.jdbc4.jar and postgres now returns the boxed types instead of the primitive arrays.

mike

Mike Traum wrote:
Hi,
I'm trying to get a mapping for postgres arrays working. I'm using a Converter and thus far (without a lot of testing), inserting an array seems to work fine. But, when reading that array, eclipselink (1.2) throws the following exception before we even get to the Converter:
java.lang.ClassCastException: [D cannot be cast to [Ljava.lang.Object;
at org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor.buildArrayObjectFromArray(ObjectRelationalDataTypeDescriptor.java:326)
...

The problem seems to be that eclipselink is attempting to cast java.sql.Array.getArray() to Object[], but postgres returns an array of primitives. This seems like an eclipselink bug, no? Any idea for a workaround?

Thanks,
Mike




------------------------------

Message: 3
Date: Mon, 16 Nov 2009 23:02:08 +0100
From: Martin Janda <jandam@xxxxxxxxxx>
Subject: [eclipselink-users] ReadAllQuery fetch all
To: EclipseLink Users <eclipselink-users@xxxxxxxxxxx>
Message-ID: <5B79C16E-9C64-4786-B33B-4A5CD86B6E61@xxxxxxxxxx>
Content-Type: text/plain;	charset=us-ascii;	format=flowed;	delsp=yes

Hello,
can you help me? please. I have Entity with lazy mappings. I need to read all Entity attributes Eager&Lazy trough ReadAllQuery (ScrollableCursor) and detach them. I need to use Entities after closing EM and EMF. So they can no longer fetch lazy mappings. I need to work with selected Entities from JTable (needs lazy) in another context (needs all attributes including lazy mappings). Is there any way how to do it in EclipseLink 1.1.3 Java SE, I prefer annotations or direct methods in EM/EMF/UOW.
Thank you very much.
    Martin

PS Sorry for my english


------------------------------

Message: 4
Date: Tue, 17 Nov 2009 14:58:09 +0100
From: Hans Harz <hansharz_eclipselink@xxxxxx>
Subject: [eclipselink-users] IndirectMap.containsKey leads to
	Exception because DISTINCT on @Lob-Field
To: eclipselink-users@xxxxxxxxxxx
Message-ID: <1852227376@xxxxxx>
Content-Type: text/plain; charset=iso-8859-15

Hi all,

I encountered a problem in our application. Maybe some of you can help me.

Using - EclipseLink 1.1.3
- Given a class A with a @Lob Field String stringValue;
- Given class B with @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    @MapKey(name = "field")
    private Map<AType, A> As;

When I call As.containsKey(someAType) on the lazy loaded map Then a Query with a DISTINCT is created.
SELECT DISTINCT ...,t0.stringValue,...
this leads to the following exception on oracle databases (and we made a test with DB2 and it also fails)
ORA-00932: inconsistent datatypes: expected - got CLOB

This is because DISTINCT queries are not allowed on BLOB or CLOB fields. Is this expected behavior? Did we miss a restriction of eclipselink? Is there a way to not generate the query without DISTINCT?

In toplink we never had this problem, so it seems that toplink did not generate the DISTINCT.

Here is the Stack Trace.

regards,
Hans

org.eclipse.persistence.exceptions.DatabaseException: Internal Exception: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got CLOB Error Code: 932 Call: SELECT DISTINCT t1.ID, t1.EXPLICITVERSION, t1.STRINGVALUE, t1.UUID, .....
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:332) org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:667) org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:512) org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:536) org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205) org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191) org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:262) org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:599) org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2518) org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2476) org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:481) org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:928) org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:664) org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:889) org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:458) org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2244) org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1181) org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1165) org.eclipse.persistence.mappings.ManyToManyMapping.extractResultFromBatchQuery(ManyToManyMapping.java:231) org.eclipse.persistence.internal.indirection.BatchValueHolder.instantiate(BatchValueHolder.java:58) org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:71) org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83) org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161) org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230) org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83) org.eclipse.persistence.indirection.IndirectMap.buildDelegate(IndirectMap.java:110) org.eclipse.persistence.indirection.IndirectMap.getDelegate(IndirectMap.java:316) org.eclipse.persistence.indirection.IndirectMap.containsKey(IndirectMap.java:165)
_____________________________________________________________
DSL-Preisknaller: DSL-Komplettpakete von WEB.DE schon für 16,99 Euro/mtl.!* Hier klicken: http://produkte.web.de/go/02/



------------------------------

Message: 5
Date: Tue, 17 Nov 2009 09:09:44 -0500
From: Tom Ware <tom.ware@xxxxxxxxxx>
Subject: Re: [eclipselink-users] ReadAllQuery fetch all
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <4B02AEA8.5020103@xxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Martin,

If you are using JPQL, JPQL allows you to specify fetch joins that will cause relationships to be automatically loaded. Have you tried that?

If you are using EclipseLink expressions, there is an addJoinedAttribute method you can use on your query.

-Tom

Martin Janda wrote:
Hello,
can you help me? please. I have Entity with lazy mappings. I need to read all Entity attributes Eager&Lazy trough ReadAllQuery (ScrollableCursor) and detach them. I need to use Entities after closing EM and EMF. So they can no longer fetch lazy mappings. I need to work with selected Entities from JTable (needs lazy) in another context (needs all attributes including lazy mappings). Is there any way how to do it in EclipseLink 1.1.3 Java SE, I prefer annotations or direct methods in EM/EMF/UOW.
Thank you very much.
   Martin

PS Sorry for my english
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


------------------------------

Message: 6
Date: Tue, 17 Nov 2009 06:38:39 -0800 (PST)
From: James Sutherland <jamesssss@xxxxxxxxx>
Subject: Re: [eclipselink-users] how can I reference a foreign key in
	ejbql	where condition?
To: eclipselink-users@xxxxxxxxxxx
Message-ID: <26391063.post@xxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=us-ascii


Why are you using a ReadAllQuery, if you are using JPA and JPQL?  Just create
a JPA Query,

Query query = em.createQuery("Select Object(entity) from ChairImpl entity
where  entity.institute=:institute");
query.setParameter("institute", new Integer(10));
List result = query.getResultList();

If you need to use a ReadAllQuery with EJBQL then you cannot use
addArgumentValue(), as it seems to have issues, you will need to execute it
as a parametrized query.

i.e.
ReadAllQuery query = new ReadAllQuery(ChairImpl.getClass());
query.setEJBQLString("Select Object(entity) from ChairImpl entity where entity.institute=?1");
   query.addArgument("1");
   EntityManager em = this.getEntityManager();
   Query query = JpaHelper.createQuery(query, em);
   query.setParameter("1", new Integer(10));
   List result = query.getResultList();


zamek42 wrote:
hello James,
thx for response.

James Sutherland wrote:
Are you using JPA?  EJBQL/JPQL is normally used from JPA using the JPA
Query interface.

For using EJBQL/JPQL with an EclipseLink ReadAllQuery you need to set the
argument names and values.

i.e.
query.setEJBQLString("Select OBJECT(sg) from sg sg where sg.foreignField
= ?1");
query.addArgument("1");
query.addArgumentValue(id);


I get filter criteria from smartgwt, which is a gwt frontend. I need ejbql
because it sends filtering criterias in a Map<String,String>. I don't want
to use an unecessary string parser, simply put criteria text into the sql.
For a test I make a simple query:

   ReadAllQuery query = new ReadAllQuery(ChairImpl.getClass());
query.setEJBQLString("Select Object(entity) from ChairImpl entity where entity.institute=?1");
   query.addArgument("1");
   query.addArgumentValue(new Integer(10));
   EntityManager em = this.getEntityManager();
   List result = JpaHelper.createQuery(query, em).getResultList();

this throws an error:
java.lang.IllegalStateException: Query argument 1 not found in the list of
parameters provided during query execution.

ChairImpl has an attribute named institute:
   @ManyToOne
    @JoinColumn(nullable=false)
    public InstituteImpl getInstitute() {
        return institute;
    }

    public void setInstitute(InstituteImpl institute) {
        this.institute = institute;
    }

What do I mistake?

Perhaps JpaHelper.createQuery is unecessary? How can I use readAllQuery
from glassfish directly?

thx Zamek



-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink , http://wiki.oracle.com/page/TopLink TopLink Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , http://www.nabble.com/EclipseLink-f26430.html EclipseLink Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence

--
Oracle <http://www.oracle.com>
Reinhard Girstenbrei | Senior Principal Technical Support Engineer
Phone: +498914302318 | Mobile: +491775941318
Oracle Oracle Customer Service

ORACLE Deutschland GmbH | Riesstr. 25 | 80992 München

ORACLE Deutschland GmbH, Hauptverwaltung: Riesstraße 25, D-80992 München
Geschäftsführer: Jürgen Kunz, Registergericht: Amtsgericht München, HRB 82775 Green Oracle <http://www.oracle.com/commitment> Oracle is committed to developing practices and products that help protect the environment



Back to the top