openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2484) JPA-QL query with byte[] projection fails.
Date Mon, 24 Mar 2014 15:48:43 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945241#comment-13945241
] 

Rick Curtis commented on OPENJPA-2484:
--------------------------------------

I think this request is within bounds of the spec. I could see a fix either being very simple
change, or very painful... most likely nothing in the middle.

> JPA-QL query with byte[] projection fails.
> ------------------------------------------
>
>                 Key: OPENJPA-2484
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2484
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.2.2
>            Reporter: Thomas Darimont
>
> Given a User entity with a persistent byte[] field declared as:
> @Lob private byte[] binaryData;
> When executing the following JPA query:
> select u.binaryData from User u where u.id = :id
> {code:java}
> 	User user = new User();
> 		user.setBinaryData("TEST".getBytes());
> 		em.persist(user);
> 		Object result = em.createQuery("select u.binaryData from User u where u.id = :id").setParameter("id",
user.getId())
> 				.getSingleResult();
>                 assertThat(result,is(notNullValue()));
> {code}
> The following exception is thrown:
> {code}
> <openjpa-2.3.0-r422266:1540826 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
Query projections cannot include array, collection, or map fields.  Invalid query: "select
u.binaryData from User u where u.id = :id"
> 	at org.apache.openjpa.kernel.ExpressionStoreQuery$AbstractExpressionExecutor.assertNotContainer(ExpressionStoreQuery.java:328)
> 	at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.<init>(ExpressionStoreQuery.java:770)
> 	at org.apache.openjpa.kernel.ExpressionStoreQuery.newDataStoreExecutor(ExpressionStoreQuery.java:179)
> 	at org.apache.openjpa.kernel.QueryImpl.createExecutor(QueryImpl.java:749)
> 	at org.apache.openjpa.kernel.QueryImpl.compileForDataStore(QueryImpl.java:707)
> 	at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:689)
> 	at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:589)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:997)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:979)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:102)
> 	at org.example.domain.OpenJpaPlainJpaTests.foo(OpenJpaPlainJpaTests.java:301)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> {code}
> Other JPA implementations like Hibernate or EclipseLink support this.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message