Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] jpox queries
[Teneo] jpox queries [message #425156] Mon, 17 November 2008 18:33 Go to next message
Greg Kirby is currently offline Greg KirbyFriend
Messages: 6
Registered: July 2009
Junior Member
We have a class ScanOperation the contains a Collection of other class
ScanJob, and ScanJob contains a field, String glassId. We need a query
that will return a ScanOperation where the contained ScanJob has a certain
glassId. I have been trying the following and getting an exception:

String select = "SELECT FROM " + ScanOperationImpl.class.getName() + "
WHERE this.contains(sj) && sj.glassId == glassId";
Query q = pm.newQuery(select);
q.declareParameters("String glassId");
q.declareVariables(ScanJobImpl.class.getName() + " sj");
List results = (List)q.execute(glassId);

the exception:
org.jpox.store.expression.ScalarExpression$MethodInvocationE xception:
Exception occurred invoking method contains(UnboundVariable
""UNBOUND_SJ"."SCAN_SCANJOB_ID"")

The jdo for the ScanOperationImpl class:

<class name="com.dupont.tcf.scan.impl.ScanOperationImpl"
requires-extent="true" persistence-modifier="persistence-capable"
detachable="true" table="scan_scanoperation" identity-type="datastore">
<implements name="com.dupont.tcf.scan.ScanOperation"/>
<implements name="org.eclipse.emf.ecore.EObject"/>
<implements name="org.eclipse.emf.common.notify.Notifier"/>
<inheritance strategy="new-table">
<discriminator column="dtype" strategy="value-map"
value="scan.ScanOperation"/>
</inheritance>
<version strategy="version-number" column="e_version"/>
<field name="group" persistence-modifier="persistent">
<collection
element-type="org.eclipse.emf.teneo.jpox.elist.GenericFeatureMapEntry ">
<extension vendor-name="jpox" key="cache-lazy-loading" value="true"/>
</collection>
<join/>
<element>
<embedded>
<field name="featurePath"/>
<field name="localAnyValue" embedded="true">
<extension vendor-name="jpox" key="implementation-classes"
value="org.eclipse.emf.teneo.jpox.mapping.AnyTypeObject"/>
<extension vendor-name="teneo" key="estructuralfeatures" value=""/>
</field>
<field name="localReferenceValue" embedded="true">
<extension vendor-name="jpox" key="implementation-classes"
value="org.eclipse.emf.teneo.jpox.mapping.AnyTypeEObject"/ >
<extension vendor-name="teneo" key="estructuralfeatures" value=""/>
<foreign-key delete-action="restrict" update-action="cascade"/>
</field>
<field name="localContainmentReferenceValue" dependent="true">
<foreign-key delete-action="cascade" update-action="cascade"/>
<extension vendor-name="jpox" key="implementation-classes"
value="com.dupont.tcf.scan.impl.ScanJobImpl"/>
<extension vendor-name="teneo" key="estructuralfeatures" value="scanJob"/>
</field>
</embedded>
</element>
<order column="SCANOPERATION_GROUP_IDX"/>
</field>
<field name="id" persistence-modifier="persistent" null-value="none"/>
<field name="idESet" persistence-modifier="persistent"/>
</class>

I'm thankful for any help you can provide. Greg
Re: [Teneo] jpox queries [message #425160 is a reply to message #425156] Mon, 17 November 2008 20:13 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Greg,
I would say that this.contains(sj) is not completely correct, I think you need to do contains on the
collection of ScanJobs, for example scanJobs.contains(sj).

gr. Maritn

Greg Kirby wrote:
> We have a class ScanOperation the contains a Collection of other class
> ScanJob, and ScanJob contains a field, String glassId. We need a query
> that will return a ScanOperation where the contained ScanJob has a
> certain glassId. I have been trying the following and getting an
> exception:
>
> String select = "SELECT FROM " + ScanOperationImpl.class.getName() + "
> WHERE this.contains(sj) && sj.glassId == glassId";
> Query q = pm.newQuery(select);
> q.declareParameters("String glassId");
> q.declareVariables(ScanJobImpl.class.getName() + " sj");
> List results = (List)q.execute(glassId);
>
> the exception:
> org.jpox.store.expression.ScalarExpression$MethodInvocationE xception:
> Exception occurred invoking method contains(UnboundVariable
> ""UNBOUND_SJ"."SCAN_SCANJOB_ID"")
>
> The jdo for the ScanOperationImpl class:
>
> <class name="com.dupont.tcf.scan.impl.ScanOperationImpl"
> requires-extent="true" persistence-modifier="persistence-capable"
> detachable="true" table="scan_scanoperation" identity-type="datastore">
> <implements name="com.dupont.tcf.scan.ScanOperation"/>
> <implements name="org.eclipse.emf.ecore.EObject"/>
> <implements name="org.eclipse.emf.common.notify.Notifier"/>
> <inheritance strategy="new-table">
> <discriminator column="dtype" strategy="value-map"
> value="scan.ScanOperation"/>
> </inheritance>
> <version strategy="version-number" column="e_version"/>
> <field name="group" persistence-modifier="persistent">
> <collection
> element-type="org.eclipse.emf.teneo.jpox.elist.GenericFeatureMapEntry ">
> <extension vendor-name="jpox" key="cache-lazy-loading" value="true"/>
> </collection>
> <join/>
> <element>
> <embedded>
> <field name="featurePath"/>
> <field name="localAnyValue" embedded="true">
> <extension vendor-name="jpox" key="implementation-classes"
> value="org.eclipse.emf.teneo.jpox.mapping.AnyTypeObject"/>
> <extension vendor-name="teneo" key="estructuralfeatures" value=""/>
> </field>
> <field name="localReferenceValue" embedded="true">
> <extension vendor-name="jpox" key="implementation-classes"
> value="org.eclipse.emf.teneo.jpox.mapping.AnyTypeEObject"/ >
> <extension vendor-name="teneo" key="estructuralfeatures" value=""/>
> <foreign-key delete-action="restrict" update-action="cascade"/>
> </field>
> <field name="localContainmentReferenceValue" dependent="true">
> <foreign-key delete-action="cascade" update-action="cascade"/>
> <extension vendor-name="jpox" key="implementation-classes"
> value="com.dupont.tcf.scan.impl.ScanJobImpl"/>
> <extension vendor-name="teneo" key="estructuralfeatures"
> value="scanJob"/>
> </field>
> </embedded>
> </element>
> <order column="SCANOPERATION_GROUP_IDX"/>
> </field>
> <field name="id" persistence-modifier="persistent" null-value="none"/>
> <field name="idESet" persistence-modifier="persistent"/>
> </class>
>
> I'm thankful for any help you can provide. Greg
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] jpox queries [message #425162 is a reply to message #425160] Mon, 17 November 2008 20:59 Go to previous messageGo to next message
Greg Kirby is currently offline Greg KirbyFriend
Messages: 6
Registered: July 2009
Junior Member
I guess I do not understand what the jdoql-string should be when querying
classes that have Collections getting mapped to a GenericFeatureMap(like
in this case ScanOperationImpl.group). I have tried the following jdoql
w/o success:

"SELECT FROM " + ScanOperationImpl.class.getName() + " WHERE
this.group.contains(sj) && (sj.glassId == glassId)";
"SELECT FROM " + ScanOperationImpl.class.getName() + " WHERE
this.group.localContainmentReferenceValue.contains(sj) && (sj.glassId ==
glassId)";

I am obviously missing the point here. Can you better explain how to get
the scanJob out of the FeatureMap?

Thanks,
Greg
Re: [Teneo] jpox queries [message #425163 is a reply to message #425162] Mon, 17 November 2008 21:40 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Greg,
I did not directly notice that it was a featuremap, sorry about that.

The honest answer is that I do not know how to do this, the collection contains embedded elements,
and the localContainmentReferenceValue or localReferenceValue point to the object you are filtering
on. I don't know how to query on embedded elements in collections for jpox/jdoql. I am afraid that
you should ask the jpox newsgroup.

Note also that Teneo only supports a old version of jpox (1.1.9). Although I really want to upgrade
to datanucleus I don't have the time to do this. I will first work on integration between Teneo and
EclipseLink.

gr. Martin

Greg Kirby wrote:
> I guess I do not understand what the jdoql-string should be when
> querying classes that have Collections getting mapped to a
> GenericFeatureMap(like in this case ScanOperationImpl.group). I have
> tried the following jdoql w/o success:
>
> "SELECT FROM " + ScanOperationImpl.class.getName() + " WHERE
> this.group.contains(sj) && (sj.glassId == glassId)";
> "SELECT FROM " + ScanOperationImpl.class.getName() + " WHERE
> this.group.localContainmentReferenceValue.contains(sj) && (sj.glassId ==
> glassId)";
>
> I am obviously missing the point here. Can you better explain how to get
> the scanJob out of the FeatureMap?
>
> Thanks,
> Greg


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] jpox queries [message #425213 is a reply to message #425163] Wed, 19 November 2008 16:37 Go to previous message
Greg Kirby is currently offline Greg KirbyFriend
Messages: 6
Registered: July 2009
Junior Member
Martin,
I got this query working using the following:

String select = "SELECT FROM " + ScanOperationImpl.class.getName() + "
WHERE this.group.contains(gfme) &&
((ScanJobImpl)gfme.localContainmentReferenceValue).glassId == glassId";
Query q = pm.newQuery(select);
q.declareParameters("String glassId");
q.declareVariables(GenericFeatureMapEntry.class.getName() + " gfme; ");
q.declareImports("import " + ScanJobImpl.class.getName() + "; import " +
String.class.getName() );
List results = (List)q.execute(glassId);

Also got it working by changing the way EMF generated the model code by
adding the attribute "ecore:featureMap=''" to the sequences in our xml
schemas. This generated the model code without using FeatureMaps, so you
could just use the following select statement:
"SELECT FROM " + ScanOperationImpl.class.getName() + " WHERE
this.scanJob.contains(sj) && sj.glassId == glassId"

Thanks for your help,
Greg
Previous Topic:CDO RecouseSet
Next Topic:Exchanging templates for generation from GenModel
Goto Forum:
  


Current Time: Sat Apr 27 03:39:26 GMT 2024

Powered by FUDForum. Page generated in 0.03101 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top