views:

304

answers:

5

SEVERE: Local Exception Stack: Exception [EclipseLink-7092] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="Voter.findAll" referenceClass=Voter jpql="SELECT v FROM Voter v")] is named: [Voter.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="Voter.findAll" referenceClass=Voter jpql="SELECT v FROM Voter v")] is named: [Voter.findAll] with arguments: [[]].

A: 

Not sure of what you're doing exactly since you're not showing any code but this is what EclipseLink documentation says about error ECLIPSELINK-07092:

ECLIPSELINK-07092: Cannot add a query whose types conflict with an existing query. Query To Be Added: [{0}] is named: [{1}] with arguments [{2}].The existing conflicting query: [{3}] is named: [{4}] with arguments: [{5}].
Cause: EclipseLink has detected a conflict between a custom query with the same name and arguments to a session.
Action: Ensure that no query is added to the session more than once or change the query name so that the query can be distinguished from others.

According to the above description and to the trace, it seems that you're adding a query (actually the same) with the same query name more than once to the session. You shouldn't (or use another query name).

Pascal Thivent
A: 

It looks like you have the query defined twice. Either on the same entity, or on another entity, or in orm.xml

Bozho
A: 

Just for the people out there that are still struggling with this error:

Undeploy your application and check if there are any stale (maybe locked) files left. This would cause the old namedqueries to still exist and thus not replacing them.

Delete the files and redeploy. The error should disappear.

Edit: Also check if you haven't done anything like ... WHERE o.object_id = :id ... instead of ... WHERE o.object = :object ...

This was the solution for my problems. Took me 3 weeks to figure that out. EclipseLink isn't very clear when it comes to exceptions. There was actually a query compile error. Instead it throws a duplicate query exception.

Benno van den Bogaard
hi, I have the same issue, do you know where could be the stale files on Glassfishv3?
coubeatczech
A: 

I encountered this problem also, I found out the exception isn't related with the error file at all, the problem is from another query for example: @NamedQuery(name = "ChannelType.ALL", query = "SELECT channelType FROM ChannelType channelType WHERE channelType.applicationClient.applicationClientId =:applicationClientId ORDER BY channelType.channelTypId ASC")

the problem is from "ORDER BY channelType.channelTypId" its not except to order by primary key ,when I remove this line the exception just gone also.

Maybe someone else could explain why this happen. Thanks

Natty
A: 

I too have come across this issue and it makes little sense. I only have one entity bean with one defined query, and it continues to tell me it's the problem. I did a stop, then start of GF3, redploy my app, and I still get it.. and worse, I am not even using the query.

One thing I don't understand.. why is EclipseLink being used in GF? Is that part of GF? I use Eclipse IDE, but I don't deploy from within Eclipse.. I deploy from my ant build script at command line. I am guessing GF must be using some EclipseLink (used to be TopLink?).

One answer above said to make sure there are no stale files, undeploy app, etc. Would be great if someone that has figured this out could provide more details and explain it. If it is another query that has an error in it, sure would be nice if the error was shown instead of this misleading one.

So far, I've stopped GF, dropped all the tables, restarted, redeployed (in autodeploy folder), and still get this issue right away. I generally build/deploy to autodeploy folder several times in short periods of time, as I make quick changes then build/redeploy.

andrew
Ok.. dang if I sent this too soon. I found out my issue. It is indeed sadly misleading. I had a bad query in one of my entities. A different class completely. Not sure why it said a different entity was the problem. Anyway, I finally fixed my query issue, redeployed, and it worked. So sadly, this error for me was because a defined NamedQuery was incorrect in its syntax. Hope that helps others. Make sure you check ALL your entities and their named queries.. their syntax. Try commenting out all of them, and one by one letting one in until you find the one that causes the misleading stack trace.
andrew