Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Distinguishing entries in tables based on some identifier
Distinguishing entries in tables based on some identifier [message #90550] Wed, 18 July 2007 19:24 Go to next message
Julia is currently offline JuliaFriend
Messages: 85
Registered: July 2009
Member
Hi MArtin,

I have a xml file stored by userid eg. application/julia/datastore.xml and
I need to have something equivalent in a database. Is there a way to add a
new column/index/something to metadata file in such a way the entries can
be distinguished by userid? I can't really change my xsd and I don't want
to create separate tables per user. Would annotation help in this case?

Julia
Re: Distinguishing entries in tables based on some identifier [message #90616 is a reply to message #90550] Wed, 18 July 2007 21:34 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Julia,
JDO/Jpox is very much driven by the java code generated from the model. So instead of changing the
meta model I would add a member (with accessors) in the generated java code. Teneo will
automatically set this member to non-persistable to solve this you have to change the jdo file
manually or extend EClassFeatureMapper and override the setNotPersistable method (which should then
make your new field persistable instead of non-persistable). Your custom EClassFeatureMapper can be
plugged-in Teneo using the extensions-mechanism as described on elver.org.

You can either add a member to each class by changing the jet template or in a superclass (if all
objects inherit from it).

Then if you don't want to explicitly set the userid in each object in your application code you can
use a jpox lifecyclelistener to set the userid just before saving an object. You can set the
lifecyclelistener in the pm.

Just some quick ideas, hope this helps.

gr. Martin

Julia wrote:
> Hi MArtin,
>
> I have a xml file stored by userid eg. application/julia/datastore.xml
> and I need to have something equivalent in a database. Is there a way to
> add a new column/index/something to metadata file in such a way the
> entries can be distinguished by userid? I can't really change my xsd and
> I don't want to create separate tables per user. Would annotation help
> in this case?
>
> Julia
>
0.8.0 / I200707181657

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Distinguishing entries in tables based on some identifier [message #91199 is a reply to message #90616] Fri, 20 July 2007 17:53 Go to previous messageGo to next message
Julia is currently offline JuliaFriend
Messages: 85
Registered: July 2009
Member
Hi Martin,

Thanks for the suggestions. That's more code changes then I expected. I
guess for a more easier fix that won't change the existing code too much,
I could add an attribute to top element eg <xs:attribute name="userid"
type="xs:ID" use="required" />. Userid become a primary key. Would I not
be able to store my individual datastore.xml(s) in the database in one set
of tables doing this way? Is that enough to be able to query by userid to
extract the same data as in the original datastore.xml?

Julia
Re: Distinguishing entries in tables based on some identifier [message #91214 is a reply to message #91199] Fri, 20 July 2007 18:48 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Julia,
Yes, but based on your post I assumed that you could not touch the model at all. If with top element
you mean the xml-root element then that is correct that by user id as the pk you are in fact storing
the dataset by user.

gr. Martin

Julia wrote:
> Hi Martin,
>
> Thanks for the suggestions. That's more code changes then I expected. I
> guess for a more easier fix that won't change the existing code too
> much, I could add an attribute to top element eg <xs:attribute
> name="userid" type="xs:ID" use="required" />. Userid become a primary
> key. Would I not be able to store my individual datastore.xml(s) in the
> database in one set of tables doing this way? Is that enough to be able
> to query by userid to extract the same data as in the original
> datastore.xml?
>
> Julia
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Distinguishing entries in tables based on some identifier [message #608801 is a reply to message #90550] Wed, 18 July 2007 21:34 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Julia,
JDO/Jpox is very much driven by the java code generated from the model. So instead of changing the
meta model I would add a member (with accessors) in the generated java code. Teneo will
automatically set this member to non-persistable to solve this you have to change the jdo file
manually or extend EClassFeatureMapper and override the setNotPersistable method (which should then
make your new field persistable instead of non-persistable). Your custom EClassFeatureMapper can be
plugged-in Teneo using the extensions-mechanism as described on elver.org.

You can either add a member to each class by changing the jet template or in a superclass (if all
objects inherit from it).

Then if you don't want to explicitly set the userid in each object in your application code you can
use a jpox lifecyclelistener to set the userid just before saving an object. You can set the
lifecyclelistener in the pm.

Just some quick ideas, hope this helps.

gr. Martin

Julia wrote:
> Hi MArtin,
>
> I have a xml file stored by userid eg. application/julia/datastore.xml
> and I need to have something equivalent in a database. Is there a way to
> add a new column/index/something to metadata file in such a way the
> entries can be distinguished by userid? I can't really change my xsd and
> I don't want to create separate tables per user. Would annotation help
> in this case?
>
> Julia
>
0.8.0 / I200707181657

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Distinguishing entries in tables based on some identifier [message #608840 is a reply to message #90616] Fri, 20 July 2007 17:53 Go to previous message
Julia is currently offline JuliaFriend
Messages: 85
Registered: July 2009
Member
Hi Martin,

Thanks for the suggestions. That's more code changes then I expected. I
guess for a more easier fix that won't change the existing code too much,
I could add an attribute to top element eg <xs:attribute name="userid"
type="xs:ID" use="required" />. Userid become a primary key. Would I not
be able to store my individual datastore.xml(s) in the database in one set
of tables doing this way? Is that enough to be able to query by userid to
extract the same data as in the original datastore.xml?

Julia
Re: Distinguishing entries in tables based on some identifier [message #608841 is a reply to message #91199] Fri, 20 July 2007 18:48 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Julia,
Yes, but based on your post I assumed that you could not touch the model at all. If with top element
you mean the xml-root element then that is correct that by user id as the pk you are in fact storing
the dataset by user.

gr. Martin

Julia wrote:
> Hi Martin,
>
> Thanks for the suggestions. That's more code changes then I expected. I
> guess for a more easier fix that won't change the existing code too
> much, I could add an attribute to top element eg <xs:attribute
> name="userid" type="xs:ID" use="required" />. Userid become a primary
> key. Would I not be able to store my individual datastore.xml(s) in the
> database in one set of tables doing this way? Is that enough to be able
> to query by userid to extract the same data as in the original
> datastore.xml?
>
> Julia
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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
Previous Topic:JET2: Invalid Java source folder
Next Topic:[Compare] Minor buglet
Goto Forum:
  


Current Time: Thu Apr 25 00:30:24 GMT 2024

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

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

Back to the top