-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JPQL SELECT NEW not joining nor recognising ElementCollection as a collection type #2264
Comments
Please attach there entities code. |
Hi @rfelcman Please find the Entity mentioned in the issue below
|
Sorry but, I don't think, that this is bug.
I don't think, that collection or array is allowed as |
I think, that this issue is duplicitous with #2193 |
Hi @rfelcman We agree with your comment about the specification. But EclipseLink still appears to have an issue, as it does not reject the usage but instead exhibits unexpected behavior by using only the value of the first element in the collection. |
Sorry, but what do You mean |
Hi @rfelcman
And the test :
When you run the tests, testQueryWithRecordResult of course will fail, but the failure message reveals that EclipseLink is returning a value for the ArrayList attribute, but it isn't a collection of String. It is a single string, seemingly a randomly chosen element of the collection. That's a bug. |
Sorry I confused about last provided example. I don't see there any JPA or EclipseLink related code. |
@rfelcman Can you try to use the above entity (RomanNumeral) and try to execute query using NEW keyword? |
There is my test case which works well see
|
Hi @rfelcman Can you try this modified one JakartaPersistence32POC_modified.zip . New test called queryNEWTest is added in this. |
But if You are mean
from modified tests where
it's incorrect as |
Hi @rfelcman You are right about the records. I was refering to Jakarta Data test. Records can be Jakarta Data entities, in which case Jakarta Data creates a separate JPA entity class that is not a record but is based on the record
Create a DTO like below :
JPQL Query :
Test case :
|
But as I mentioned above array or collection is not allowed by Jakarta Persistence spec |
I just read through this issue and there are a lot of mistakes in representing the Jakarta Data scenario, including some in the latest attempt. @ajaypaul-ibm please make sure you can run the test yourself before posting it for Radek to look at. You should have it log the output of the query to System.out and be able to post an example of what the corrupted output looks like when running the test. For purposes of demonstrating the unexpected behavior, I would get rid of the asserts. They obscure what is actually being returned. Later if you want an automated test, you can put them back in then.
Definitely. The problem is that EclipseLink is NOT disallowing the collection attribute and instead successfully runs the query and returns wrong data. That is what Ajay is attempting to demonstrate. Thanks for all of your patience here. I think he is getting close to doing so. |
EclipseLink is rejecting JPQL SELECT NEW clauses where an entity contains an attribute that is an ElementCollection.
For example,
SELECT o.comments FROM Rating o WHERE o.id = :id
where the columncomments
is an ElementCollection is correctly returned as a result set.We can see from the SQL generated by EclipseLink that a JOIN is required to get the data from the
Rating_COMMENTS
table:However, when we try to use
o.comments
in aSELECT NEW
query like the one below:The following error is thrown:
I would have expected EclipseLink to be able to satisfy this JPQL query with a SQL Query something like:
The text was updated successfully, but these errors were encountered: