Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » To EMF or Not to EMF
To EMF or Not to EMF [message #422968] Fri, 19 September 2008 16:43 Go to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
All,

I have taken up to write this to lay out my quandary and to learn what I
can from the responses of others if any.

I began using EMF a few months ago because I found its promises appealing.
I liked the idea of generating code, that was consistently structured and
had things like notification and serialization build in. I relished the
prospect of supporting queries against a large, EMF based data structure;
and of easy persistence to a database.

I did some experimentation. I did a real project with a smallish model and
was encouraged to take this EMF thing further. That's when things began
to take a turn for the worse. I began to be blindsided by issues wrt EMF.
The root cause of these seems to stem from an attempt to support
many-to-many relationships in the model. I find that when I do this,
things work differently in EMF than in plain ole java.

I found I had to start using the anyURI data type coupled with
ecore:reference to get my many-to-many to behave properly. Then I
encountered dangling reference issues when I attempted to do a save. Now,
having gotten past all that, I find that EMF query doesn't yield a result
in any situation where anyURI and ecore:reference have been used. I
shutter to think what teneo might do with a model like this. (I harangued
for three hours trying to teneo to persist even a trivial EMF model and
gave it up. I went instead with a pojo and hibernate annotations and was
done in minutes.)

I am willing to accept that I may still be doing something wrong but the
cost of the learning curve is proving to be quite a bit greater than I
expected. I am faced with a decision of whether to continue and make this
EMF thing work or start back pedaling. I am probably going to back pedal.


I regret this. The potential of EMF is compelling but I am at a place
where I can't afford to get in any further just to have some other issue
arise that forces me to change my schema in a way that rips through my
code, or worse yet, find out I simply can't get there from here.

Any similar experiences out there?
Re: To EMF or Not to EMF [message #422969 is a reply to message #422968] Fri, 19 September 2008 17:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Geoffry,
I am sorry to hear that you had problems working with EMF/Teneo. Teneo works fine with
ecore:reference/anyUri and hql also works (if you look for querying).

Regarding Teneo I only saw one post from you regarding use of hibernate.properties and I replied on
that one.
Let me know if I might have missed other posts you placed on this newsgroup regarding difficulties
you encountered with Teneo.

gr. Martin

Geoffry Roberts wrote:
> All,
>
> I have taken up to write this to lay out my quandary and to learn what I
> can from the responses of others if any.
>
> I began using EMF a few months ago because I found its promises
> appealing. I liked the idea of generating code, that was consistently
> structured and had things like notification and serialization build in.
> I relished the prospect of supporting queries against a large, EMF based
> data structure; and of easy persistence to a database.
>
> I did some experimentation. I did a real project with a smallish model
> and was encouraged to take this EMF thing further. That's when things
> began to take a turn for the worse. I began to be blindsided by issues
> wrt EMF. The root cause of these seems to stem from an attempt to
> support many-to-many relationships in the model. I find that when I do
> this, things work differently in EMF than in plain ole java.
>
> I found I had to start using the anyURI data type coupled with
> ecore:reference to get my many-to-many to behave properly. Then I
> encountered dangling reference issues when I attempted to do a save.
> Now, having gotten past all that, I find that EMF query doesn't yield a
> result in any situation where anyURI and ecore:reference have been
> used. I shutter to think what teneo might do with a model like this.
> (I harangued for three hours trying to teneo to persist even a trivial
> EMF model and gave it up. I went instead with a pojo and hibernate
> annotations and was done in minutes.)
>
> I am willing to accept that I may still be doing something wrong but the
> cost of the learning curve is proving to be quite a bit greater than I
> expected. I am faced with a decision of whether to continue and make
> this EMF thing work or start back pedaling. I am probably going to back
> pedal.
>
> I regret this. The potential of EMF is compelling but I am at a place
> where I can't afford to get in any further just to have some other issue
> arise that forces me to change my schema in a way that rips through my
> code, or worse yet, find out I simply can't get there from here.
>
> Any similar experiences out there?
>


--

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: To EMF or Not to EMF [message #422970 is a reply to message #422968] Fri, 19 September 2008 17:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Geoffry,

Good subject line. :-P Comments below.


Geoffry Roberts wrote:
> All,
>
> I have taken up to write this to lay out my quandary and to learn what
> I can from the responses of others if any.
>
> I began using EMF a few months ago because I found its promises
> appealing. I liked the idea of generating code, that was consistently
> structured and had things like notification and serialization build
> in. I relished the prospect of supporting queries against a large,
> EMF based data structure; and of easy persistence to a database.
>
> I did some experimentation. I did a real project with a smallish model
> and was encouraged to take this EMF thing further. That's when things
> began to take a turn for the worse. I began to be blindsided by
> issues wrt EMF. The root cause of these seems to stem from an attempt
> to support many-to-many relationships in the model. I find that when
> I do this, things work differently in EMF than in plain ole java.
Given that plain ole Java doesn't support this without reams of complex
code that exceedingly difficult to get right, that shouldn't be too
shocking... Of course if you use pojos, you can manage both ends as if
they didn't need to be consistent, but that seems to be asking for a
different set of problems...
>
> I found I had to start using the anyURI data type coupled with
> ecore:reference to get my many-to-many to behave properly.
So it's an XML Schema-based model...
> Then I encountered dangling reference issues when I attempted to do
> a save.
So neither end is a containment reference, which stands to reason since
a container reference can't be a many...
> Now, having gotten past all that, I find that EMF query doesn't yield
> a result in any situation where anyURI and ecore:reference have been
> used.
Not sure I follow. You mean the EMF Query component's technology?
> I shutter to think what teneo might do with a model like this. (I
> harangued for three hours trying to teneo to persist even a trivial
> EMF model and gave it up. I went instead with a pojo and hibernate
> annotations and was done in minutes.)
Teneo supports these JPA annotations. I know for sure it works on these
types of models...
>
> I am willing to accept that I may still be doing something wrong but
> the cost of the learning curve is proving to be quite a bit greater
> than I expected.
For the many-many things in combination with Teneo specifically I guess...
> I am faced with a decision of whether to continue and make this EMF
> thing work or start back pedaling. I am probably going to back pedal.
Have you ask the specific questions about Teneo's support for
many-to-many references?
>
> I regret this. The potential of EMF is compelling but I am at a place
> where I can't afford to get in any further just to have some other
> issue arise that forces me to change my schema in a way that rips
> through my code, or worse yet, find out I simply can't get there from
> here.
I'm not sure the relation between the schema changes and the code
ripping....
>
> Any similar experiences out there?
I'm sure Martin will read your post.... The Library model can easily be
turned into a case like this by adding maxOccurs="unbounded" to the
Writer.books element. Does that reproduce the problems you are seeing.
I'd strongly encourage you to state your specific problem in the form of
a concrete example against which we can provide concrete advice. The
library example is well understood, so that seems like a good basis for
describing a generic many-to-many reference problem.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: To EMF or Not to EMF [message #422971 is a reply to message #422968] Fri, 19 September 2008 17:11 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Geoffry,

I'd bet everybody on this newgroup would say "EMF rocks"! If there
really were people with a different opinon I'm sure they don't subscribe
to this list anymore ;-)

That said, EMF, with it's hundreds of APIs, is certainly not the very
easiest stuff to learn. But the benefit will be high and the best thing
you can do is asking the newsgroup for help with particular technical
problems. Availability of advice is almost ever a matter of minutes here!

Cheers
/Eike


Geoffry Roberts schrieb:
> All,
>
> I have taken up to write this to lay out my quandary and to learn what
> I can from the responses of others if any.
>
> I began using EMF a few months ago because I found its promises
> appealing. I liked the idea of generating code, that was consistently
> structured and had things like notification and serialization build
> in. I relished the prospect of supporting queries against a large,
> EMF based data structure; and of easy persistence to a database.
>
> I did some experimentation. I did a real project with a smallish model
> and was encouraged to take this EMF thing further. That's when things
> began to take a turn for the worse. I began to be blindsided by
> issues wrt EMF. The root cause of these seems to stem from an attempt
> to support many-to-many relationships in the model. I find that when
> I do this, things work differently in EMF than in plain ole java.
>
> I found I had to start using the anyURI data type coupled with
> ecore:reference to get my many-to-many to behave properly. Then I
> encountered dangling reference issues when I attempted to do a save.
> Now, having gotten past all that, I find that EMF query doesn't yield
> a result in any situation where anyURI and ecore:reference have been
> used. I shutter to think what teneo might do with a model like this.
> (I harangued for three hours trying to teneo to persist even a trivial
> EMF model and gave it up. I went instead with a pojo and hibernate
> annotations and was done in minutes.)
>
> I am willing to accept that I may still be doing something wrong but
> the cost of the learning curve is proving to be quite a bit greater
> than I expected. I am faced with a decision of whether to continue
> and make this EMF thing work or start back pedaling. I am probably
> going to back pedal.
>
> I regret this. The potential of EMF is compelling but I am at a place
> where I can't afford to get in any further just to have some other
> issue arise that forces me to change my schema in a way that rips
> through my code, or worse yet, find out I simply can't get there from
> here.
>
> Any similar experiences out there?
>


Re: To EMF or Not to EMF [message #422977 is a reply to message #422970] Fri, 19 September 2008 18:28 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Ed Merks wrote:

Thanks for the response Ed. You and I have corresponded before so some of
what I'll lay out might be familiar.

> Geoffry,

> Good subject line. :-P Comments below.

>> I found I had to start using the anyURI data type coupled with
>> ecore:reference to get my many-to-many to behave properly.
> So it's an XML Schema-based model...
>> Then I encountered dangling reference issues when I attempted to do
>> a save.
> So neither end is a containment reference, which stands to reason since
> a container reference can't be a many...

My many to many situation is with people and diseases. Many people can
have a given disease. A given person can have many diseases. The use of
anyURI enables this relationship but introduces the dangling reference
issue because the disease side of the relation is, as you pointed out, not
a container reference. Is containment simply a matter of creating a
complexType in my schema that holds a sequence with an unbounded set of
all diseases? If so, must I duplicate this complexType for each EMF
structure I need to support?

I keep my diseases in the database, but my people are created and updated
at run time and if they are persisted at all it is via serialization when
we might snapshot the state of the population.

>> Now, having gotten past all that, I find that EMF query doesn't yield
>> a result in any situation where anyURI and ecore:reference have been
>> used.
> Not sure I follow. You mean the EMF Query component's technology?

I think so. If I take my EList of people and query for a simple attribute
like zcta or isHealthy, I get a proper result. If I query for people with
a disease by title, keeping in mind that disease is linked in via the
anyURI type, the query finds nothing. What I really want is to find
people from a zcta, with a disease at a particular stage--a triple .and.
situation.

Query is attractive as a way to update the model as disease cases are
streamed in by various health care facilities. The model holds some 300K
people (the tourist population of Las Vegas at any given moment in time)
who come and go with the flight schedules.

> Teneo supports these JPA annotations. I know for sure it works on these
> types of models...

Good to know. I haven't gotten into it that deeply yet.


> Have you ask the specific questions about Teneo's support for
> many-to-many references?

Asked once and received good advice.
Re: To EMF or Not to EMF [message #422978 is a reply to message #422977] Fri, 19 September 2008 18:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Geoffry,

Comments below.


Geoffry Roberts wrote:
> Ed Merks wrote:
>
> Thanks for the response Ed. You and I have corresponded before so
> some of what I'll lay out might be familiar.
>
>> Geoffry,
>
>> Good subject line. :-P Comments below.
>
>>> I found I had to start using the anyURI data type coupled with
>>> ecore:reference to get my many-to-many to behave properly.
>> So it's an XML Schema-based model...
>>> Then I encountered dangling reference issues when I attempted to
>>> do a save.
>> So neither end is a containment reference, which stands to reason
>> since a container reference can't be a many...
>
> My many to many situation is with people and diseases. Many people
> can have a given disease.
I remember that thread...
> A given person can have many diseases. The use of anyURI enables this
> relationship but introduces the dangling reference issue because the
> disease side of the relation is, as you pointed out, not a container
> reference. Is containment simply a matter of creating a complexType
> in my schema that holds a sequence with an unbounded set of all diseases?
Yes.
> If so, must I duplicate this complexType for each EMF structure I need
> to support?
XML doesn't really support multiple roots, so you can't just have
multiple children directly in the resource which XMI does support.
It's possible to create a container that can contain any object. An
element of type AnyType would support that. In that way you could have
a generic container...
> I keep my diseases in the database, but my people are created and
> updated at run time and if they are persisted at all it is via
> serialization when we might snapshot the state of the population.
The OHF folks e.g., Dan Ford) are using EMF for spread of disease
modeling...
>>> Now, having gotten past all that, I find that EMF query doesn't
>>> yield a result in any situation where anyURI and ecore:reference
>>> have been used.
>> Not sure I follow. You mean the EMF Query component's technology?
>
> I think so. If I take my EList of people and query for a simple
> attribute like zcta or isHealthy, I get a proper result. If I query
> for people with a disease by title, keeping in mind that disease is
> linked in via the anyURI type, the query finds nothing. What I really
> want is to find people from a zcta, with a disease at a particular
> stage--a triple .and. situation.
I don't know much about how Query works. Christian is likely to comment.
>
> Query is attractive as a way to update the model as disease cases are
> streamed in by various health care facilities. The model holds some
> 300K people (the tourist population of Las Vegas at any given moment
> in time) who come and go with the flight schedules.
I think if you use Teneo, you can use HBQL (I think that's what it's
called) directly too...
>
>> Teneo supports these JPA annotations. I know for sure it works on
>> these types of models...
>
> Good to know. I haven't gotten into it that deeply yet.
>
>
>> Have you ask the specific questions about Teneo's support for
>> many-to-many references?
>
> Asked once and received good advice.
As Eike mentioned, there are lots of people willing to help with
concrete problems... It's often the case that something that seems very
complex up front, seems quite simple in hindsight...
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: To EMF or Not to EMF [message #422980 is a reply to message #422978] Fri, 19 September 2008 18:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Geoffry, Ed,

On the subject of EMF Query, I do recall a thread involving multi-step
joins between persons and zctas and such. The exchange kinda fizzled ...

The EMF Query component never did get into any kind of integration with
persistence layers like Teneo. In such cases, I would think that the
performance and expressiveness of the "native" query language (such as
HQL) will supersede the EMF Query, anyway. It totally wouldn't scale,
as it is geared towards the classic EMF in-memory resource set. EMF
Query would end up loading the entire database into memory. Queries
belong on the RDBMS, IMO.

Cheers,

Christian

Ed Merks wrote:
> Geoffry,
>
> Comments below.
>
>
> Geoffry Roberts wrote:
>> Ed Merks wrote:
>>
>> Thanks for the response Ed. You and I have corresponded before so
>> some of what I'll lay out might be familiar.
>>
>>> Geoffry,
>>
>>> Good subject line. :-P Comments below.
>>
>>>> I found I had to start using the anyURI data type coupled with
>>>> ecore:reference to get my many-to-many to behave properly.
>>> So it's an XML Schema-based model...
>>>> Then I encountered dangling reference issues when I attempted to
>>>> do a save.
>>> So neither end is a containment reference, which stands to reason
>>> since a container reference can't be a many...
>>
>> My many to many situation is with people and diseases. Many people
>> can have a given disease.
> I remember that thread...
>> A given person can have many diseases. The use of anyURI enables this
>> relationship but introduces the dangling reference issue because the
>> disease side of the relation is, as you pointed out, not a container
>> reference. Is containment simply a matter of creating a complexType
>> in my schema that holds a sequence with an unbounded set of all diseases?
> Yes.
>> If so, must I duplicate this complexType for each EMF structure I need
>> to support?
> XML doesn't really support multiple roots, so you can't just have
> multiple children directly in the resource which XMI does support.
> It's possible to create a container that can contain any object. An
> element of type AnyType would support that. In that way you could have
> a generic container...
>> I keep my diseases in the database, but my people are created and
>> updated at run time and if they are persisted at all it is via
>> serialization when we might snapshot the state of the population.
> The OHF folks e.g., Dan Ford) are using EMF for spread of disease
> modeling...
>>>> Now, having gotten past all that, I find that EMF query doesn't
>>>> yield a result in any situation where anyURI and ecore:reference
>>>> have been used.
>>> Not sure I follow. You mean the EMF Query component's technology?
>>
>> I think so. If I take my EList of people and query for a simple
>> attribute like zcta or isHealthy, I get a proper result. If I query
>> for people with a disease by title, keeping in mind that disease is
>> linked in via the anyURI type, the query finds nothing. What I really
>> want is to find people from a zcta, with a disease at a particular
>> stage--a triple .and. situation.
> I don't know much about how Query works. Christian is likely to comment.
>>
>> Query is attractive as a way to update the model as disease cases are
>> streamed in by various health care facilities. The model holds some
>> 300K people (the tourist population of Las Vegas at any given moment
>> in time) who come and go with the flight schedules.
> I think if you use Teneo, you can use HBQL (I think that's what it's
> called) directly too...
>>
>>> Teneo supports these JPA annotations. I know for sure it works on
>>> these types of models...
>>
>> Good to know. I haven't gotten into it that deeply yet.
>>
>>
>>> Have you ask the specific questions about Teneo's support for
>>> many-to-many references?
>>
>> Asked once and received good advice.
> As Eike mentioned, there are lots of people willing to help with
> concrete problems... It's often the case that something that seems very
> complex up front, seems quite simple in hindsight...
>>
>>
Re: To EMF or Not to EMF [message #422981 is a reply to message #422969] Fri, 19 September 2008 19:03 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Martin Taal wrote:

> Hi Geoffry,
> I am sorry to hear that you had problems working with EMF/Teneo. Teneo works
fine with
> ecore:reference/anyUri and hql also works (if you look for querying).

> Regarding Teneo I only saw one post from you regarding use of
hibernate.properties and I replied on
> that one.

I remember your reply and it was bang on. Thanks.

My big concerns wrt teneo, apart from getting it to work initially, are
what will my database schema look like if I let teneo create it? will my
admin. be able to populate it without changing his loaders too much? what
does teneo do when say add a column?
Re: To EMF or Not to EMF [message #422982 is a reply to message #422980] Fri, 19 September 2008 19:20 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Christian W. Damus wrote:

> Hi, Geoffry, Ed,

> On the subject of EMF Query, I do recall a thread involving multi-step
> joins between persons and zctas and such. The exchange kinda fizzled ...

It fizzled because I had to go off and do some other things--I'm back.

> The EMF Query component never did get into any kind of integration with
> persistence layers like Teneo. In such cases, I would think that the
> performance and expressiveness of the "native" query language (such as
> HQL) will supersede the EMF Query, anyway. It totally wouldn't scale,
> as it is geared towards the classic EMF in-memory resource set. EMF
> Query would end up loading the entire database into memory. Queries
> belong on the RDBMS, IMO.

If you recall what I wrote to Ed earlier in this thread, my persons are
not persisted in a database. I keep them in memory, the model changes in
real time based on incoming data streams. There are some 300k people
coming from all over the world. I'm trying to decide whether to use EMF
Query or to find what I'm looking for by looping through the thing.



The following describes the problem. Further below, I give my bits code

My many to many situation is with people and diseases. Many people can
have a given disease. A given person can have many diseases. The use of
anyURI enables this relationship.

I've included the EMF structures I'm using below. Further below are the
two queries I'm testing with, one works one doesn't.


<!-- Some 300K people are contained here. -->
<xs:complexType name="EpiPersons">
<xs:sequence>
<xs:element name="epiPerson" type="per:EpiPerson" maxOccurs="unbounded"/>
... more stuff ...
</xs:sequence>
</xs:complexType>

<!-- Each person has an epidemiological state -->
<xs:complexType name="EpiPerson">
<xs:sequence>
<xs:element name="personState" type="PersonState"/>
... more stuff ...
</xs:sequence>
</xs:complexType>

<!-- Each epidemiological state can contain a number of disease states -->
<xs:complexType name="PersonState">
<xs:sequence>
<xs:element name="states" type="dis:State" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<!-- Each disease state has a disease associated with it. -->
<xs:complexType name="State">
<xs:sequence>
<xs:element name="disease" type="xs:anyURI" ecore:reference="Disease"/>
<xs:element name="effectiveContact" type="xs:boolean"/>
... more stuff ...
<xs:sequence>
</xs:complexType>


The queries:
// Yields a good result.

EpiPersons epiPersons = // gets created somehow
BooleanCondition eff = new BooleanCondition(true);
EObjectAttributeValueCondition condition = new
EObjectAttributeValueCondition (
DiseasePackage.Literals.STATE__EFFECTIVE_CONTACT, eff);
WHERE where = new WHERE(condition);
FROM from = new FROM(epiPersons);
SELECT select = new SELECT(from, where);
IQueryResult result = select.execute();
Set set = result.getEObjects();


// Yields nothing.

EpiPersons epiPersons = // gets created somehow
StringCondition title = new StringValue("influenza");
EObjectAttributeValueCondition condition = new
EObjectAttributeValueCondition (
DiseasePackage.Literals.DISEASE__TITLE, title);
WHERE where = new WHERE(condition);
FROM from = new FROM(epiPersons);
SELECT select = new SELECT(from, where);
IQueryResult result = select.execute();
Set set = result.getEObjects();
Re: To EMF or Not to EMF [message #422983 is a reply to message #422981] Fri, 19 September 2008 19:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Geoffry,
Teneo creates a hibernate mapping and lets hibernate create and update the db. Regarding the
database schema there are number of things which are decided by Teneo (and placed in the hbm). Most
(if not all) default mapping decisions can be overridden by options/annotations:
1- table/column/fk naming: the default behavior can be overridden by either setting a different
naming strategy or by setting jpa annotations in the model.
2- Use a join table for a one-to-many association, this is controlled by options or by annotations.
3- Teneo adds columns to store econtainer relations, this can be disabled through an option
4- Teneo chooses cascade types based on containment or non-contaiment. You can influence the default
cascade types by options or by annotations
5- location of foreign key field (for bidirectional one-to-one)

I would let Teneo create a first database schema and then you can check how your database schema
looks like. It should be pretty readable and look as a standard relational schema.

One thing to take into account is that EMF uses lists as the collection type. This means that
Teneo/hibernate will create columns to store the list index. Hibernate does not support
bi-directional lists. So this can also be disabled (map everything as a set or idbag) by options and
annotations.
http://www.elver.org/hibernate/hibernate_relations.html

Teneo supports all jpa annotations and a fair amount of hibernate annotations
http://www.elver.org/hibernate/ejb3_features.html

Here are some other links:
http://www.elver.org/hibernate/options.html
http://www.elver.org/hibernate/extensions.html
http://www.elver.org/hibernate/ejb3_format.html

When you add a column Teneo will create a new mapping. Depending on your hibernate options,
hibernate will add a new column.

gr. Martin

Geoffry Roberts wrote:
> Martin Taal wrote:
>
>> Hi Geoffry,
>> I am sorry to hear that you had problems working with EMF/Teneo. Teneo
>> works
> fine with
>> ecore:reference/anyUri and hql also works (if you look for querying).
>
>> Regarding Teneo I only saw one post from you regarding use of
> hibernate.properties and I replied on
>> that one.
>
> I remember your reply and it was bang on. Thanks.
>
> My big concerns wrt teneo, apart from getting it to work initially, are
> what will my database schema look like if I let teneo create it? will my
> admin. be able to populate it without changing his loaders too much?
> what does teneo do when say add a column?
>


--

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: To EMF or Not to EMF [message #422984 is a reply to message #422982] Fri, 19 September 2008 20:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Geoffry,

It looks to me like this query:

> EpiPersons epiPersons = // gets created somehow
> StringCondition title = new StringValue("influenza");
> EObjectAttributeValueCondition condition = new
> EObjectAttributeValueCondition (
> DiseasePackage.Literals.DISEASE__TITLE, title);
> WHERE where = new WHERE(condition);
> FROM from = new FROM(epiPersons);
> SELECT select = new SELECT(from, where);
> IQueryResult result = select.execute();
> Set set = result.getEObjects();

is searching for Diseases in an EpiPersons object that have the title
"influenza." Are Diseases nested within the EpiPersons in your schema?
I don't see that they are, from the way you describe the partitioning
of your data between the database and memory. This particular query is
not using your anyURI reference at all; it isn't being asked to.

If your query is supposed to find persons that have influenza, then it
will have to specify a join through the EpiPerson::personState,
PersonState::state, and State::disease EReferences. Try this:

EpiPersons epiPersons = // gets created somehow
StringCondition title = new StringValue("influenza");
EObjectAttributeValueCondition condition = new
EObjectAttributeValueCondition (
DiseasePackage.Literals.DISEASE__TITLE, title);
EObjectReferenceValueCondition hasDisease = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.STATE__DISEASE,
condition);
EObjectReferenceValueCondition hasState = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.PERSON_STATE__STATE,
hasDisease);
EObjectReferenceValueCondition hasPersonState = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.EPI_PERSON__PERSON_STATE,
condition);
WHERE where = new WHERE(hasPersonState);
FROM from = new FROM(epiPersons);
SELECT select = new SELECT(from, where);
IQueryResult result = select.execute();
Set set = result.getEObjects();

This, I think, will return EpiPerson instances that are linked to the
influena Disease.

HTH,

Christian


Geoffry Roberts wrote:
> Christian W. Damus wrote:
>
>> Hi, Geoffry, Ed,
>
>> On the subject of EMF Query, I do recall a thread involving multi-step
>> joins between persons and zctas and such. The exchange kinda fizzled ...
>
> It fizzled because I had to go off and do some other things--I'm back.
>
>> The EMF Query component never did get into any kind of integration
>> with persistence layers like Teneo. In such cases, I would think that
>> the performance and expressiveness of the "native" query language
>> (such as HQL) will supersede the EMF Query, anyway. It totally
>> wouldn't scale, as it is geared towards the classic EMF in-memory
>> resource set. EMF Query would end up loading the entire database into
>> memory. Queries belong on the RDBMS, IMO.
>
> If you recall what I wrote to Ed earlier in this thread, my persons are
> not persisted in a database. I keep them in memory, the model changes
> in real time based on incoming data streams. There are some 300k people
> coming from all over the world. I'm trying to decide whether to use EMF
> Query or to find what I'm looking for by looping through the thing.
>
>
> The following describes the problem. Further below, I give my bits code
> My many to many situation is with people and diseases. Many people can
> have a given disease. A given person can have many diseases. The use
> of anyURI enables this relationship.
>
> I've included the EMF structures I'm using below. Further below are the
> two queries I'm testing with, one works one doesn't.
>
>
> <!-- Some 300K people are contained here. -->
> <xs:complexType name="EpiPersons">
> <xs:sequence>
> <xs:element name="epiPerson" type="per:EpiPerson" maxOccurs="unbounded"/>
> ... more stuff ...
> </xs:sequence>
> </xs:complexType>
>
> <!-- Each person has an epidemiological state -->
> <xs:complexType name="EpiPerson">
> <xs:sequence>
> <xs:element name="personState" type="PersonState"/>
> ... more stuff ...
> </xs:sequence>
> </xs:complexType>
>
> <!-- Each epidemiological state can contain a number of disease states -->
> <xs:complexType name="PersonState">
> <xs:sequence>
> <xs:element name="states" type="dis:State" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
>
> <!-- Each disease state has a disease associated with it. -->
> <xs:complexType name="State">
> <xs:sequence>
> <xs:element name="disease" type="xs:anyURI" ecore:reference="Disease"/>
> <xs:element name="effectiveContact" type="xs:boolean"/>
> ... more stuff ...
> <xs:sequence>
> </xs:complexType>
>
>
> The queries:
> // Yields a good result.
>
> EpiPersons epiPersons = // gets created somehow
> BooleanCondition eff = new BooleanCondition(true);
> EObjectAttributeValueCondition condition = new
> EObjectAttributeValueCondition (
> DiseasePackage.Literals.STATE__EFFECTIVE_CONTACT, eff);
> WHERE where = new WHERE(condition);
> FROM from = new FROM(epiPersons);
> SELECT select = new SELECT(from, where);
> IQueryResult result = select.execute();
> Set set = result.getEObjects();
>
>
> // Yields nothing.
>
> EpiPersons epiPersons = // gets created somehow
> StringCondition title = new StringValue("influenza");
> EObjectAttributeValueCondition condition = new
> EObjectAttributeValueCondition (
> DiseasePackage.Literals.DISEASE__TITLE, title);
> WHERE where = new WHERE(condition);
> FROM from = new FROM(epiPersons);
> SELECT select = new SELECT(from, where);
> IQueryResult result = select.execute();
> Set set = result.getEObjects();
>
>
Re: To EMF or Not to EMF [message #422986 is a reply to message #422984] Fri, 19 September 2008 20:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Sorry, copy/paste error. Should be:

EpiPersons epiPersons = // gets created somehow
StringCondition title = new StringValue("influenza");
EObjectAttributeValueCondition condition = new
EObjectAttributeValueCondition (
DiseasePackage.Literals.DISEASE__TITLE, title);
EObjectReferenceValueCondition hasDisease = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.STATE__DISEASE,
condition);
EObjectReferenceValueCondition hasState = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.PERSON_STATE__STATE,
hasDisease);
EObjectReferenceValueCondition hasPersonState = new
EObjectReferenceValueCondition(
DiseasePackage.Literals.EPI_PERSON__PERSON_STATE,
*hasState* );
WHERE where = new WHERE(hasPersonState);
FROM from = new FROM(epiPersons);
SELECT select = new SELECT(from, where);
IQueryResult result = select.execute();
Set set = result.getEObjects();


cW

Christian W. Damus wrote:
> Hi, Geoffry,
>
> It looks to me like this query:
>
> > EpiPersons epiPersons = // gets created somehow
> > StringCondition title = new StringValue("influenza");
> > EObjectAttributeValueCondition condition = new
> > EObjectAttributeValueCondition (
> > DiseasePackage.Literals.DISEASE__TITLE, title);
> > WHERE where = new WHERE(condition);
> > FROM from = new FROM(epiPersons);
> > SELECT select = new SELECT(from, where);
> > IQueryResult result = select.execute();
> > Set set = result.getEObjects();
>
> is searching for Diseases in an EpiPersons object that have the title
> "influenza." Are Diseases nested within the EpiPersons in your schema?
> I don't see that they are, from the way you describe the partitioning
> of your data between the database and memory. This particular query is
> not using your anyURI reference at all; it isn't being asked to.
>
> If your query is supposed to find persons that have influenza, then it
> will have to specify a join through the EpiPerson::personState,
> PersonState::state, and State::disease EReferences. Try this:
>
> EpiPersons epiPersons = // gets created somehow
> StringCondition title = new StringValue("influenza");
> EObjectAttributeValueCondition condition = new
> EObjectAttributeValueCondition (
> DiseasePackage.Literals.DISEASE__TITLE, title);
> EObjectReferenceValueCondition hasDisease = new
> EObjectReferenceValueCondition(
> DiseasePackage.Literals.STATE__DISEASE,
> condition);
> EObjectReferenceValueCondition hasState = new
> EObjectReferenceValueCondition(
> DiseasePackage.Literals.PERSON_STATE__STATE,
> hasDisease);
> EObjectReferenceValueCondition hasPersonState = new
> EObjectReferenceValueCondition(
> DiseasePackage.Literals.EPI_PERSON__PERSON_STATE,
> condition);
> WHERE where = new WHERE(hasPersonState);
> FROM from = new FROM(epiPersons);
> SELECT select = new SELECT(from, where);
> IQueryResult result = select.execute();
> Set set = result.getEObjects();
>
> This, I think, will return EpiPerson instances that are linked to the
> influena Disease.
>
> HTH,
>
> Christian
>
>
> Geoffry Roberts wrote:
>> Christian W. Damus wrote:
>>
>>> Hi, Geoffry, Ed,
>>
>>> On the subject of EMF Query, I do recall a thread involving
>>> multi-step joins between persons and zctas and such. The exchange
>>> kinda fizzled ...
>>
>> It fizzled because I had to go off and do some other things--I'm back.
>>
>>> The EMF Query component never did get into any kind of integration
>>> with persistence layers like Teneo. In such cases, I would think
>>> that the performance and expressiveness of the "native" query
>>> language (such as HQL) will supersede the EMF Query, anyway. It
>>> totally wouldn't scale, as it is geared towards the classic EMF
>>> in-memory resource set. EMF Query would end up loading the entire
>>> database into memory. Queries belong on the RDBMS, IMO.
>>
>> If you recall what I wrote to Ed earlier in this thread, my persons
>> are not persisted in a database. I keep them in memory, the model
>> changes in real time based on incoming data streams. There are some
>> 300k people coming from all over the world. I'm trying to decide
>> whether to use EMF Query or to find what I'm looking for by looping
>> through the thing.
>>
>> The following describes the problem. Further below, I give my bits
>> code My many to many situation is with people and diseases. Many
>> people can have a given disease. A given person can have many
>> diseases. The use of anyURI enables this relationship.
>>
>> I've included the EMF structures I'm using below. Further below are
>> the two queries I'm testing with, one works one doesn't.
>>
>>
>> <!-- Some 300K people are contained here. -->
>> <xs:complexType name="EpiPersons">
>> <xs:sequence>
>> <xs:element name="epiPerson" type="per:EpiPerson"
>> maxOccurs="unbounded"/>
>> ... more stuff ...
>> </xs:sequence>
>> </xs:complexType>
>>
>> <!-- Each person has an epidemiological state -->
>> <xs:complexType name="EpiPerson">
>> <xs:sequence>
>> <xs:element name="personState" type="PersonState"/>
>> ... more stuff ...
>> </xs:sequence>
>> </xs:complexType>
>>
>> <!-- Each epidemiological state can contain a number of disease states
>> -->
>> <xs:complexType name="PersonState">
>> <xs:sequence>
>> <xs:element name="states" type="dis:State" maxOccurs="unbounded"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <!-- Each disease state has a disease associated with it. -->
>> <xs:complexType name="State">
>> <xs:sequence>
>> <xs:element name="disease" type="xs:anyURI"
>> ecore:reference="Disease"/>
>> <xs:element name="effectiveContact" type="xs:boolean"/>
>> ... more stuff ...
>> <xs:sequence>
>> </xs:complexType>
>>
>>
>> The queries:
>> // Yields a good result.
>>
>> EpiPersons epiPersons = // gets created somehow
>> BooleanCondition eff = new BooleanCondition(true);
>> EObjectAttributeValueCondition condition = new
>> EObjectAttributeValueCondition (
>> DiseasePackage.Literals.STATE__EFFECTIVE_CONTACT, eff);
>> WHERE where = new WHERE(condition);
>> FROM from = new FROM(epiPersons);
>> SELECT select = new SELECT(from, where);
>> IQueryResult result = select.execute();
>> Set set = result.getEObjects();
>>
>>
>> // Yields nothing.
>>
>> EpiPersons epiPersons = // gets created somehow
>> StringCondition title = new StringValue("influenza");
>> EObjectAttributeValueCondition condition = new
>> EObjectAttributeValueCondition (
>> DiseasePackage.Literals.DISEASE__TITLE, title);
>> WHERE where = new WHERE(condition);
>> FROM from = new FROM(epiPersons);
>> SELECT select = new SELECT(from, where);
>> IQueryResult result = select.execute();
>> Set set = result.getEObjects();
>>
>>
Re: To EMF or Not to EMF [message #423079 is a reply to message #422986] Mon, 22 September 2008 17:02 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Christian,

Thanks Christian. I had a sneaky feeling that I needed to do something
similar to your example. Having you spell it out for me is most helpful.
It was the prospect of hours of trial and error that I found so daunting.
Adding such an example to the current documentation would be a good idea
in my view.

At one level, I can appreciate your sentiments on querying being best left
to databases, but on another level having capability to efficiently query
data structure such as EMF is valuable for my needs. I would hate to go
through the mishmash of persisting these epi-persons for no more purpose
that to run a query.

Something that might help EMF query would be some kind of query builder
tool that would help in building correct queries and conversely in
discovering the errors of ones ways in queries that worketh not.
Re: To EMF or Not to EMF [message #423080 is a reply to message #422983] Mon, 22 September 2008 17:05 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Martin Taal wrote:

> (if not all) default mapping decisions can be overridden by
options/annotations:

This is good to know, but I wonder if I am generating my EMF will such
annotations survive a regeneration?
Re: To EMF or Not to EMF [message #423081 is a reply to message #423080] Mon, 22 September 2008 17:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
The annotations can be specified in the model (xsd or ecore) or in a separate xml file. The
regeneration will pick them up from there so they won't be overwritten.

gr. Martin

Geoffry Roberts wrote:
> Martin Taal wrote:
>
>> (if not all) default mapping decisions can be overridden by
> options/annotations:
>
> This is good to know, but I wonder if I am generating my EMF will such
> annotations survive a regeneration?
>


--

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: To EMF or Not to EMF [message #423086 is a reply to message #423081] Mon, 22 September 2008 20:07 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 71
Registered: July 2009
Member
Martin Taal wrote:

> The annotations can be specified in the model (xsd or ecore) or in a
separate xml file. The
> regeneration will pick them up from there so they won't be overwritten.

I had no idea Good to know. Can you give an example of how one would spec
an annotation in xsd?

> gr. Martin

> Geoffry Roberts wrote:
>> Martin Taal wrote:
>>
>>> (if not all) default mapping decisions can be overridden by
>> options/annotations:
>>
>> This is good to know, but I wonder if I am generating my EMF will such
>> annotations survive a regeneration?
>>
Re: To EMF or Not to EMF [message #423088 is a reply to message #423086] Mon, 22 September 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 Geoffry,
See here:
http://www.elver.org/hibernate/ejb3_examples.html#schemasamp les
http://www.elver.org/hibernate/ejb3_format.html#simplenokeyv alye

gr. Martin

Geoffry Roberts wrote:
> Martin Taal wrote:
>
>> The annotations can be specified in the model (xsd or ecore) or in a
> separate xml file. The
>> regeneration will pick them up from there so they won't be overwritten.
>
> I had no idea Good to know. Can you give an example of how one would
> spec an annotation in xsd?
>
>> gr. Martin
>
>> Geoffry Roberts wrote:
>>> Martin Taal wrote:
>>>
>>>> (if not all) default mapping decisions can be overridden by
>>> options/annotations:
>>>
>>> This is good to know, but I wonder if I am generating my EMF will
>>> such annotations survive a regeneration?
>>>
>
>
>
>


--

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: To EMF or Not to EMF [message #423089 is a reply to message #423079] Mon, 22 September 2008 20:40 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Geoffry,

See some replies in-line, below.

Cheers,

Christian

Geoffry Roberts wrote:
> Christian,
>
> Thanks Christian. I had a sneaky feeling that I needed to do something
> similar to your example. Having you spell it out for me is most
> helpful. It was the prospect of hours of trial and error that I found

No problem. It was good practice for me ;-)


> so daunting. Adding such an example to the current documentation would
> be a good idea in my view.

Sounds like a contribution! :-)


> At one level, I can appreciate your sentiments on querying being best
> left to databases, but on another level having capability to efficiently
> query data structure such as EMF is valuable for my needs. I would hate
> to go through the mishmash of persisting these epi-persons for no more
> purpose that to run a query.

One of the issues to consider in evaluating the EMF Query component is
whether its generality is worth the obfuscation of the code. One
important misconception to dispel (if you have such) is in the
efficiency of queries. The queries built using this API are not any
more efficient than an eAllContents() iterator over the starting
collection of EObjects with a hand-coded test (including pruning), which
often will be easier to read and to comprehend.

The real benefit of this API is in applications that need to define
complex conditions and to re-combine them in various ways, possibly even
with different iteration strategies. I haven't seen many such applications.


> Something that might help EMF query would be some kind of query builder
> tool that would help in building correct queries and conversely in
> discovering the errors of ones ways in queries that worketh not.

Absolutely. That is just the sort of feature development that this
component needs in order to re-invigorate it, and exactly the kind that
I am not in a position to do. If you are, it could be fun.
Previous Topic:[Data Binding] Table viewer and EMF Data Binding.
Next Topic:How to convert XMIResource to CDOResource
Goto Forum:
  


Current Time: Fri Mar 29 02:36:47 GMT 2024

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

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

Back to the top