
|
If you were logged in you would be able to see more operations.
|
|
|
|
The SQL created for Querying a Set with contains for a FCO is incorrect. It does produce the correct result but there are severe performance issues. An example test will be attached.
But the simple test case discussed in the forums is repeated below, along with required change suggested by Erik,
Example:
2 classes A, B.
A has SET of Bs.
MetaData:
<jdo>
<package name="org.jpox.test">
<class name="A" table="A">
<datastore-identity strategy="increment" column="JDOIDX"/>
<inheritance>
<discriminator strategy="class-name" column="JDOCLASSX"/>
</inheritance>
<version strategy="version-number" column="JDOLOCKX"/>
<field name="set" table="A_SET">
<collection element-type="B"/>
<join column="JDOIDX"/>
<element column="BX"/>
</field>
<field name="name" column="NAMEX"/>
</class>
<class name="B" table="B">
<datastore-identity strategy="increment" column="JDOIDX"/>
<inheritance>
<discriminator strategy="class-name" column="JDOCLASSX"/>
</inheritance>
<version strategy="version-number" column="JDOLOCKX"/>
<field name="name" column="NAMEX"/>
</class>
</package>
</jdo>
Query of form:
query = pm.newQuery(A.class, "set.contains(b)");
query.declareParameters( "org.jpox.test.B b" );
Erik's suggestion:
SELECT `THIS`.`JDOCLASSX`,`THIS`.`JDOIDX`,`THIS`.`JDOLOCKX`,`THIS`.`NAMEX`
FROM `A` `THIS`
WHERE EXISTS (
SELECT 1 FROM `A_SET` `THIS_SET`,
`B` `THIS_SET_1`
WHERE `THIS_SET`.`JDOIDX` = `THIS`.`JDOIDX` AND
`THIS_SET_1`.`JDOIDX` = `THIS_SET`.`BX` AND
<1> = `THIS_SET_1`.`JDOIDX` AND
`THIS`.`JDOCLASSX` = <'org.jpox.test.A'>
)
could have been
SELECT `THIS`.`JDOCLASSX`,`THIS`.`JDOIDX`,`THIS`.`JDOLOCKX`,`THIS`.`NAMEX`
FROM `A` `THIS`
WHERE EXISTS (
SELECT 1 FROM `A_SET` `THIS_SET`
WHERE `THIS_SET`.`JDOIDX` = `THIS`.`JDOIDX` AND
<1> = `THIS_SET`.`BX` AND
`THIS`.`JDOCLASSX` = <'org.jpox.test.A'>
)
|
|
Description
|
The SQL created for Querying a Set with contains for a FCO is incorrect. It does produce the correct result but there are severe performance issues. An example test will be attached.
But the simple test case discussed in the forums is repeated below, along with required change suggested by Erik,
Example:
2 classes A, B.
A has SET of Bs.
MetaData:
<jdo>
<package name="org.jpox.test">
<class name="A" table="A">
<datastore-identity strategy="increment" column="JDOIDX"/>
<inheritance>
<discriminator strategy="class-name" column="JDOCLASSX"/>
</inheritance>
<version strategy="version-number" column="JDOLOCKX"/>
<field name="set" table="A_SET">
<collection element-type="B"/>
<join column="JDOIDX"/>
<element column="BX"/>
</field>
<field name="name" column="NAMEX"/>
</class>
<class name="B" table="B">
<datastore-identity strategy="increment" column="JDOIDX"/>
<inheritance>
<discriminator strategy="class-name" column="JDOCLASSX"/>
</inheritance>
<version strategy="version-number" column="JDOLOCKX"/>
<field name="name" column="NAMEX"/>
</class>
</package>
</jdo>
Query of form:
query = pm.newQuery(A.class, "set.contains(b)");
query.declareParameters( "org.jpox.test.B b" );
Erik's suggestion:
SELECT `THIS`.`JDOCLASSX`,`THIS`.`JDOIDX`,`THIS`.`JDOLOCKX`,`THIS`.`NAMEX`
FROM `A` `THIS`
WHERE EXISTS (
SELECT 1 FROM `A_SET` `THIS_SET`,
`B` `THIS_SET_1`
WHERE `THIS_SET`.`JDOIDX` = `THIS`.`JDOIDX` AND
`THIS_SET_1`.`JDOIDX` = `THIS_SET`.`BX` AND
<1> = `THIS_SET_1`.`JDOIDX` AND
`THIS`.`JDOCLASSX` = <'org.jpox.test.A'>
)
could have been
SELECT `THIS`.`JDOCLASSX`,`THIS`.`JDOIDX`,`THIS`.`JDOLOCKX`,`THIS`.`NAMEX`
FROM `A` `THIS`
WHERE EXISTS (
SELECT 1 FROM `A_SET` `THIS_SET`
WHERE `THIS_SET`.`JDOIDX` = `THIS`.`JDOIDX` AND
<1> = `THIS_SET`.`BX` AND
`THIS`.`JDOCLASSX` = <'org.jpox.test.A'>
)
|
Show » |
Sort Order:
|