[
https://issues.apache.org/jira/browse/OPENJPA-2179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266087#comment-13266087
]
Albert Lee commented on OPENJPA-2179:
-------------------------------------
I am see the following exception in TestOracleDistinctJoin.testJoinOnly, ONLY
in Oracle 10g
Caused by: <openjpa-2.3.0-SNAPSHOT-rexported fatal store error>
org.apache.openjpa.persistence.EntityExistsException: ORA-01400: cannot insert
NULL into ("SCOTT"."COURSE"."COURSEID")
{prepstmnt 87607598 INSERT INTO SCOTT.Course (ID, COURSENUMBER, LOBCOLUMN,
NORMALATTRIBUTE, OPTLOCK, OBJECTIVEDE, OBJECTIVEEN) VALUES (?, ?, ?, ?, ?, ?,
?)} [code=1400, state=23000]
FailedObject: org.apache.openjpa.jdbc.oracle.Course@13124d36
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4910)
at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4885)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:143)
at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.batchOrExecuteRow(BatchingPreparedStatementManagerImpl.java:100)
at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:83)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:106)
at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:735)
at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
... 37 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01400: cannot
insert NULL into ("SCOTT"."COURSE"."COURSEID")
{prepstmnt 87607598 INSERT INTO SCOTT.Course (ID, COURSENUMBER, LOBCOLUMN,
NORMALATTRIBUTE, OPTLOCK, OBJECTIVEDE, OBJECTIVEEN) VALUES (?, ?, ?, ?, ?, ?,
?)} [code=1400, state=23000]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:195)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:59)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1134)
at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:272)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1763)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:267)
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:118)
... 48 more
> 'distinct' and 'join' combinations lead lots of unneccessary sub-queries for
> @Embedded and @Lob fields
> ------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2179
> URL: https://issues.apache.org/jira/browse/OPENJPA-2179
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2179-test-1.patch
>
>
> I have an Entity (Course) with a simple @Embedded field and a @Lob. I do not
> use any LAZY attribution on them!
> If I do a normal em.find, the entity will be loaded as a whole (all the
> fields, including the embedded and the lob will be fetched immediately).
> Sidenote: the Lecturer referred in the select is defined as
> @OneToMany(mappedBy = "course",
> cascade = {CascadeType.PERSIST, CascadeType.REMOVE,
> CascadeType.MERGE},
> orphanRemoval = true, fetch = FetchType.EAGER)
> @OrderColumn(name = "POSITION")
> private List<Lecturer> lecturers;
> The following selects DO work
> * "select c from Course c join c.lecturers l "
> * "select distinct c from Course c"
> The following selects create tons of subqueries! 1 separate sub-query for
> each @Embedded field, and also for each @Lob
> * "select distinct c from Course c join c.lecturers l "
> * "select distinct c from Lecturer l join l.course c"
> * "select c from Lecturer l join l.course c"
> This happens ONLY if I run this stuff against Oracle. In MySQL it seems to
> work properly.
> I'll try to create a unit test for it.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira