[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] IndirectMap.containsKey leads to Exception because DISTINCT on @Lob-Field
|
Hi James, Hi Reinhard,
thank you very much for your answers.
I'm not sure about your suggested workaround. How can I set the dontUseDistinct() property on the query, when I don't specify the query manually.
Is there a annotation based possibility on the Many-to-Many property?
Right now the field in the owning class looks like this:
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
@MapKey(name = "typeId")
@XStreamAlias("customFields")
private Map<CustomFieldType, CustomFieldValue> customFields;
and the CustomFieldValue class contains the Clob Field
@Lob
@Column(nullable = true)
@XStreamAlias("stringValue")
private String stringValue;
I searched the API and documentation but can't find anything.
Because the exception appeared at one of our customers a hint to a workaround through editing the persistence.xml and the orm.xml would be great.
Thanks in advance,
Hans
> -----Ursprüngliche Nachricht-----
> Von: "James Sutherland" <jamesssss@xxxxxxxxx>
> Gesendet: 17.11.09 19:42:42
> An: eclipselink-users@xxxxxxxxxxx
> Betreff: Re: [eclipselink-users] IndirectMap.containsKey leads to Exception because DISTINCT on @Lob-Field
>
> The distinct is used because you are using batch reading on the query. If
> you do not set batch reading on the query then you will not have the issue.
> Batch reading uses a distinct to avoid fetching duplicate data. You can
> disable the usage of the distinct by setting dontUseDistinct() on the
> original batch query. But then you will be selecting duplicate potentially.
>
> You could also try moving the Lob to another table, or use a fetch group
> (LAZY) on the Lob to avoid selecting it by default.
>
> We could probably try to auto-detect a Lob field in the descriptor and not
> add the distinct, so you could log a bug for that.
>
>
> Hans Harz-2 wrote:
> >
> > 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/
> >
> >
>
>
> -----
> 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
> --
> View this message in context: http://old.nabble.com/IndirectMap.containsKey-leads-to-Exception-because-DISTINCT-on-%40Lob-Field-tp26390360p26395252.html
> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
_____________________________________________________________
DSL-Preisknaller: DSL-Komplettpakete von WEB.DE schon für
16,99 Euro/mtl.!* Hier klicken: http://produkte.web.de/go/02/