Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] legacy database and hibernate mappings
[Teneo] legacy database and hibernate mappings [message #134859] Fri, 10 April 2009 14:37 Go to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
EMF+Teneo+Hibernate+Spring+RCP

I would like to use Teneo for hibernate access to legacy database. The
relationships between tables is not 100% well-defined. In some places
the relationships exist, in others they must be enforced through the
application. Over time, some fields may be added to the tables and some
tables may be added but that is under a separate change management cycle
not solely controlled by our group.

I would like to use Teneo so that we can adapt to database changes that
we and other groups ask for as well as allow other groups to extend our
ecore models and more easily update our application to suit their needs.
Essentially they might extend the database and respectively extend the
model. I realize that I can model and generate schema updates in forward
modeling but that change cycle is not always allowed for the application
groups.


Questions on some best practices to help with this:

a) How do I indicate hibernate options for the table name and columns
directly in the ecore model? Object names and table names do not match
nor do we want them to (the legacy names are very unfriendly)? We also
need to add sql queries and other tricks to get relationships to work in
the objects. We only have an ecore model. Typically we model through the
ecore diagram tool. There is no XSD or annotated java classes to
derive from. I have used teneo to generate an hbm file but I don't think
that this is the right place to put the hibernate options and it does
not appear to be a good idea to place the annotations on the generated
classes either. What's the best practice for this? Are their teneo
properties that replace hibernate properties that I should use instead?

b) If someone writes a new method in our domain object and we want to
automatically bring that operation back into our ecore, how do we do
that (merge java domain objects bakc into ecore)? This is not strictly a
teneo question.

c) Some objects that we want in our application do not map to a single
table in the legacy database but to 3-4 tables that must be joined. How
do I indicate this for teneo? This question is related to (1).

I've read through the teneo wiki but am not sure I saw obvious answers
to these questions.
Re: [Teneo] legacy database and hibernate mappings [message #134872 is a reply to message #134859] Fri, 10 April 2009 21:34 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi apdev,
With Teneo you can accomplish most of the mapping issues with annotations in the model.Either in the ecore itself or in
a separate xml file. This is described here: http://www.elver.org (is this what you mean with Teneo wiki?).
For example table and column naming is set using Table and Column annotations. You can also implement your own sql
naming strategy if that is easier:
http://www.elver.org/hibernate/extensions.html

I think Ed can answer question b better than I do, I would say model the same operation in ecore and generate from
there, but maybe there are better options.

For question c you can use SecundaryTable annotations.

The supported annotations are listed here:
http://www.elver.org/hibernate/ejb3_features.html

Let me know if you miss a hibernate-specific annotation, they are normally easy to add.

Here are examples of annotated models (in ecore and xml):
http://www.elver.org/hibernate/ejb3_examples.html

btw, support for Teneo is given on the main EMF newsgroup (which I put on the cc).

gr. Martin

aappddeevv wrote:
> EMF+Teneo+Hibernate+Spring+RCP
>
> I would like to use Teneo for hibernate access to legacy database. The
> relationships between tables is not 100% well-defined. In some places
> the relationships exist, in others they must be enforced through the
> application. Over time, some fields may be added to the tables and some
> tables may be added but that is under a separate change management cycle
> not solely controlled by our group.
>
> I would like to use Teneo so that we can adapt to database changes that
> we and other groups ask for as well as allow other groups to extend our
> ecore models and more easily update our application to suit their needs.
> Essentially they might extend the database and respectively extend the
> model. I realize that I can model and generate schema updates in forward
> modeling but that change cycle is not always allowed for the application
> groups.
>
>
> Questions on some best practices to help with this:
>
> a) How do I indicate hibernate options for the table name and columns
> directly in the ecore model? Object names and table names do not match
> nor do we want them to (the legacy names are very unfriendly)? We also
> need to add sql queries and other tricks to get relationships to work in
> the objects. We only have an ecore model. Typically we model through the
> ecore diagram tool. There is no XSD or annotated java classes to derive
> from. I have used teneo to generate an hbm file but I don't think that
> this is the right place to put the hibernate options and it does not
> appear to be a good idea to place the annotations on the generated
> classes either. What's the best practice for this? Are their teneo
> properties that replace hibernate properties that I should use instead?
>
> b) If someone writes a new method in our domain object and we want to
> automatically bring that operation back into our ecore, how do we do
> that (merge java domain objects bakc into ecore)? This is not strictly a
> teneo question.
>
> c) Some objects that we want in our application do not map to a single
> table in the legacy database but to 3-4 tables that must be joined. How
> do I indicate this for teneo? This question is related to (1).
>
> I've read through the teneo wiki but am not sure I saw obvious answers
> to these questions.


--

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] legacy database and hibernate mappings [message #134885 is a reply to message #134872] Fri, 10 April 2009 21:56 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Before you decide to use Teneo for your *RCP* application I think that
you might reconsider it. Teneo inherits the hibernate "problem" that it
is created for short time transactions and is not really useable for
long term concurrency (at least this is my way of thinking).

So if you have multiple people are using your application at the same
time you'll maybe run into trouble. IMHO the combination of Teneo and
CDO is unbeatable for such a scenario though don't know the current
state of the CDO-Teneo backend.

Tom

Martin Taal schrieb:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>
> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #134898 is a reply to message #134872] Fri, 10 April 2009 23:31 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Martin Taal wrote:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>

Based on your comments, since I am starting with an ecore model (instead
of an XSD or annotated java class), it appears that I need to add teneo
annotations to the ecore model (which I can do through the
diagram interface).

If I use this approach, is there a teneo.hibernate corresponding to the
teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.

Can I also assume that once I generate the java classes, I can
initialize my HbDataStore using the factory and the hibernate
annotations will be passed along properly to the underlying hibernate
engine? It looks like from experiments that the generated java classes
do not have the annotations itself.

Is this right?


> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #134911 is a reply to message #134872] Fri, 10 April 2009 23:32 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Martin Taal wrote:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>

Based on your comments, since I am starting with an ecore model (instead
of an XSD or annotated java class), it appears that I need to add teneo
annotations to the ecore model (which I can do through the
diagram interface).

If I use this approach, is there a teneo.hibernate corresponding to the
teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.

Can I also assume that once I generate the java classes, I can
initialize my HbDataStore using the factory and the hibernate
annotations will be passed along properly to the underlying hibernate
engine? It looks like from experiments that the generated java classes
do not have the annotations itself.

Is this right?


> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #134925 is a reply to message #134885] Fri, 10 April 2009 23:32 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Tom,
Regarding long transactions. A Hibernate session can be kept open indefinitely while you use multiple transactions (over
time) to read extra data. Then at a certain point in time you can flush the state of the session to the database. This
is also the mode used in Seam to support conversations over multiple (http) requests.
I fully understand that this is only a small part of the long term concurrency story but still wanted to mention it for
the record.

For the rest I fully agree that CDO itself and the combination of CDO/Teneo is a very good solution for a RCP. Teneo
standalone is more server oriented (for example in case of webservices, or when server side logic is an important part
of the solution). Also when you need (HQL) querying or need practically full support of all EMF/XSD model constructs
then Teneo is a good solution.

Regarding the CDO/Teneo backend, currently 33 of the around 390 testcases fail. I hope to spend a few hours per week on
this.

gr. Martin

Tom Schindl wrote:
> Hi,
>
> Before you decide to use Teneo for your *RCP* application I think that
> you might reconsider it. Teneo inherits the hibernate "problem" that it
> is created for short time transactions and is not really useable for
> long term concurrency (at least this is my way of thinking).
>
> So if you have multiple people are using your application at the same
> time you'll maybe run into trouble. IMHO the combination of Teneo and
> CDO is unbeatable for such a scenario though don't know the current
> state of the CDO-Teneo backend.
>
> Tom
>
> Martin Taal schrieb:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate xml
>> file. This is described here: http://www.elver.org (is this what you
>> mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if that
>> is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>> I think Ed can answer question b better than I do, I would say model the
>> same operation in ecore and generate from there, but maybe there are
>> better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database. The
>>> relationships between tables is not 100% well-defined. In some places
>>> the relationships exist, in others they must be enforced through the
>>> application. Over time, some fields may be added to the tables and
>>> some tables may be added but that is under a separate change
>>> management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to suit
>>> their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and generate
>>> schema updates in forward modeling but that change cycle is not always
>>> allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not match
>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>> need to add sql queries and other tricks to get relationships to work
>>> in the objects. We only have an ecore model. Typically we model
>>> through the ecore diagram tool. There is no XSD or annotated java
>>> classes to derive from. I have used teneo to generate an hbm file but
>>> I don't think that this is the right place to put the hibernate
>>> options and it does not appear to be a good idea to place the
>>> annotations on the generated classes either. What's the best practice
>>> for this? Are their teneo properties that replace hibernate properties
>>> that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>> a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a single
>>> table in the legacy database but to 3-4 tables that must be joined.
>>> How do I indicate this for teneo? This question is related to (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>> to these questions.
>>


--

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] legacy database and hibernate mappings [message #134937 is a reply to message #134911] Fri, 10 April 2009 23:40 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi apdev,
See comments inline marked with MT>>

gr. Martin

aappddeevv wrote:
> Martin Taal wrote:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate
>> xml file. This is described here: http://www.elver.org (is this what
>> you mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if
>> that is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>
> Based on your comments, since I am starting with an ecore model (instead
> of an XSD or annotated java class), it appears that I need to add teneo
> annotations to the ecore model (which I can do through the
> diagram interface).
>
> If I use this approach, is there a teneo.hibernate corresponding to the
> teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.
MT>> The annotations in the model are all JPA (so you should use teneo.jpa) with support for some hibernate specific
annotations. At runtime you can choose to initialize the datastore for standard hibernate (the default:
HbSessionDataStore) or want to use Hibernate Entity Manager (HbEntityDataStore). In your case you should use the
HbSessionDataStore. So only when defining the annotations in the model you should know JPA (the annotations), at runtime
you can use classic Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).

>
> Can I also assume that once I generate the java classes, I can
> initialize my HbDataStore using the factory and the hibernate
> annotations will be passed along properly to the underlying hibernate
> engine? It looks like from experiments that the generated java classes
> do not have the annotations itself.
MT>> Correct, based on the annotations and the model itself, Teneo generates a hbm in-memory and passes this on to
hibernate at startup. You can find the hbm when calling the method getMappingXML on the datastore.

>
> Is this right?
>
>
>> I think Ed can answer question b better than I do, I would say model
>> the same operation in ecore and generate from there, but maybe there
>> are better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database.
>>> The relationships between tables is not 100% well-defined. In some
>>> places the relationships exist, in others they must be enforced
>>> through the application. Over time, some fields may be added to the
>>> tables and some tables may be added but that is under a separate
>>> change management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to
>>> suit their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and
>>> generate schema updates in forward modeling but that change cycle is
>>> not always allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not
>>> match nor do we want them to (the legacy names are very unfriendly)?
>>> We also need to add sql queries and other tricks to get relationships
>>> to work in the objects. We only have an ecore model. Typically we
>>> model through the ecore diagram tool. There is no XSD or annotated
>>> java classes to derive from. I have used teneo to generate an hbm
>>> file but I don't think that this is the right place to put the
>>> hibernate options and it does not appear to be a good idea to place
>>> the annotations on the generated classes either. What's the best
>>> practice for this? Are their teneo properties that replace hibernate
>>> properties that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not
>>> strictly a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a
>>> single table in the legacy database but to 3-4 tables that must be
>>> joined. How do I indicate this for teneo? This question is related to
>>> (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious
>>> answers to these questions.
>>
>>


--

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] legacy database and hibernate mappings [message #134950 is a reply to message #134885] Sat, 11 April 2009 00:33 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Tom Schindl wrote:
> Hi,
>
> Before you decide to use Teneo for your *RCP* application I think that
> you might reconsider it. Teneo inherits the hibernate "problem" that it
> is created for short time transactions and is not really useable for
> long term concurrency (at least this is my way of thinking).
>

Yes. I looked into this issue over a long period of time and blogged a
bunch of thoughts. For RCP when using spring (which I like) I found that
I needed to use the orchestra long session scope (its a pacakge off of
the myfaces package) that intercepts all methods and swaps in the proper
session before the method call. This makes the rest of spring behave
consistently. Of course, you can just hold onto the session object and
not use spring transactions. There no easy conversation/session
management like in jboss's seam for RCP.

I have not found any good material on session management for RCP
applications except that for some "editors" a long session is a must and
for high latency connections, a long session is needed as well. To be
honest, I have found that it takes alot of skill to balance session
lifetime, lazy loading and units of work.

I have looked at CDO but could not determine enough about it to
understand session management. I liked the concept though and thought
the wiki documentation was a good start. All together, EMF, teneo and
CDO is quite an impressive stack.

Tom, since I believe you have good insights I will look into CDO again
especially around conversations.




> So if you have multiple people are using your application at the same
> time you'll maybe run into trouble. IMHO the combination of Teneo and
> CDO is unbeatable for such a scenario though don't know the current
> state of the CDO-Teneo backend.
>
> Tom
>
> Martin Taal schrieb:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate xml
>> file. This is described here: http://www.elver.org (is this what you
>> mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if that
>> is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>> I think Ed can answer question b better than I do, I would say model the
>> same operation in ecore and generate from there, but maybe there are
>> better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database. The
>>> relationships between tables is not 100% well-defined. In some places
>>> the relationships exist, in others they must be enforced through the
>>> application. Over time, some fields may be added to the tables and
>>> some tables may be added but that is under a separate change
>>> management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to suit
>>> their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and generate
>>> schema updates in forward modeling but that change cycle is not always
>>> allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not match
>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>> need to add sql queries and other tricks to get relationships to work
>>> in the objects. We only have an ecore model. Typically we model
>>> through the ecore diagram tool. There is no XSD or annotated java
>>> classes to derive from. I have used teneo to generate an hbm file but
>>> I don't think that this is the right place to put the hibernate
>>> options and it does not appear to be a good idea to place the
>>> annotations on the generated classes either. What's the best practice
>>> for this? Are their teneo properties that replace hibernate properties
>>> that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>> a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a single
>>> table in the legacy database but to 3-4 tables that must be joined.
>>> How do I indicate this for teneo? This question is related to (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>> to these questions.
>>
Re: [Teneo] legacy database and hibernate mappings [message #134963 is a reply to message #134937] Sat, 11 April 2009 00:39 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Thanks. I believe this answers this first question.

Now if I can just figure out the diagramming tool a bit more I should be
in good shape :-)



Martin Taal wrote:
> Hi apdev,
> See comments inline marked with MT>>
>
> gr. Martin
>
> aappddeevv wrote:
>> Martin Taal wrote:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate
>>> xml file. This is described here: http://www.elver.org (is this what
>>> you mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if
>>> that is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>
>> Based on your comments, since I am starting with an ecore model
>> (instead of an XSD or annotated java class), it appears that I need to
>> add teneo annotations to the ecore model (which I can do through the
>> diagram interface).
>>
>> If I use this approach, is there a teneo.hibernate corresponding to
>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>> hibernate.
> MT>> The annotations in the model are all JPA (so you should use
> teneo.jpa) with support for some hibernate specific annotations. At
> runtime you can choose to initialize the datastore for standard
> hibernate (the default: HbSessionDataStore) or want to use Hibernate
> Entity Manager (HbEntityDataStore). In your case you should use the
> HbSessionDataStore. So only when defining the annotations in the model
> you should know JPA (the annotations), at runtime you can use classic
> Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).
>
>>
>> Can I also assume that once I generate the java classes, I can
>> initialize my HbDataStore using the factory and the hibernate
>> annotations will be passed along properly to the underlying hibernate
>> engine? It looks like from experiments that the generated java classes
>> do not have the annotations itself.
> MT>> Correct, based on the annotations and the model itself, Teneo
> generates a hbm in-memory and passes this on to hibernate at startup.
> You can find the hbm when calling the method getMappingXML on the
> datastore.
>
>>
>> Is this right?
>>
>>
>>> I think Ed can answer question b better than I do, I would say model
>>> the same operation in ecore and generate from there, but maybe there
>>> are better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>> put on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database.
>>>> The relationships between tables is not 100% well-defined. In some
>>>> places the relationships exist, in others they must be enforced
>>>> through the application. Over time, some fields may be added to the
>>>> tables and some tables may be added but that is under a separate
>>>> change management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to
>>>> suit their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and
>>>> generate schema updates in forward modeling but that change cycle is
>>>> not always allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and
>>>> columns directly in the ecore model? Object names and table names do
>>>> not match nor do we want them to (the legacy names are very
>>>> unfriendly)? We also need to add sql queries and other tricks to get
>>>> relationships to work in the objects. We only have an ecore model.
>>>> Typically we model through the ecore diagram tool. There is no XSD
>>>> or annotated java classes to derive from. I have used teneo to
>>>> generate an hbm file but I don't think that this is the right place
>>>> to put the hibernate options and it does not appear to be a good
>>>> idea to place the annotations on the generated classes either.
>>>> What's the best practice for this? Are their teneo properties that
>>>> replace hibernate properties that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want
>>>> to automatically bring that operation back into our ecore, how do we
>>>> do that (merge java domain objects bakc into ecore)? This is not
>>>> strictly a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a
>>>> single table in the legacy database but to 3-4 tables that must be
>>>> joined. How do I indicate this for teneo? This question is related
>>>> to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>> answers to these questions.
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #134974 is a reply to message #134950] Sat, 11 April 2009 01:07 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

You should check out the RCP-Application I wrote for EclipseCon and the
slides I provide there.

The slides are:
https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/EC2009/446

The source code for the complete application:
http://github.com/tomsontom/emf-databinding-example/tree/mas ter

Tom

aappddeevv schrieb:
> Tom Schindl wrote:
>> Hi,
>>
>> Before you decide to use Teneo for your *RCP* application I think that
>> you might reconsider it. Teneo inherits the hibernate "problem" that it
>> is created for short time transactions and is not really useable for
>> long term concurrency (at least this is my way of thinking).
>>
>
> Yes. I looked into this issue over a long period of time and blogged a
> bunch of thoughts. For RCP when using spring (which I like) I found that
> I needed to use the orchestra long session scope (its a pacakge off of
> the myfaces package) that intercepts all methods and swaps in the proper
> session before the method call. This makes the rest of spring behave
> consistently. Of course, you can just hold onto the session object and
> not use spring transactions. There no easy conversation/session
> management like in jboss's seam for RCP.
>
> I have not found any good material on session management for RCP
> applications except that for some "editors" a long session is a must and
> for high latency connections, a long session is needed as well. To be
> honest, I have found that it takes alot of skill to balance session
> lifetime, lazy loading and units of work.
>
> I have looked at CDO but could not determine enough about it to
> understand session management. I liked the concept though and thought
> the wiki documentation was a good start. All together, EMF, teneo and
> CDO is quite an impressive stack.
>
> Tom, since I believe you have good insights I will look into CDO again
> especially around conversations.
>
>
>
>
>> So if you have multiple people are using your application at the same
>> time you'll maybe run into trouble. IMHO the combination of Teneo and
>> CDO is unbeatable for such a scenario though don't know the current
>> state of the CDO-Teneo backend.
>>
>> Tom
>>
>> Martin Taal schrieb:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate xml
>>> file. This is described here: http://www.elver.org (is this what you
>>> mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if that
>>> is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>> I think Ed can answer question b better than I do, I would say model the
>>> same operation in ecore and generate from there, but maybe there are
>>> better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>>> on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database. The
>>>> relationships between tables is not 100% well-defined. In some places
>>>> the relationships exist, in others they must be enforced through the
>>>> application. Over time, some fields may be added to the tables and
>>>> some tables may be added but that is under a separate change
>>>> management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to suit
>>>> their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and generate
>>>> schema updates in forward modeling but that change cycle is not always
>>>> allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and columns
>>>> directly in the ecore model? Object names and table names do not match
>>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>>> need to add sql queries and other tricks to get relationships to work
>>>> in the objects. We only have an ecore model. Typically we model
>>>> through the ecore diagram tool. There is no XSD or annotated java
>>>> classes to derive from. I have used teneo to generate an hbm file but
>>>> I don't think that this is the right place to put the hibernate
>>>> options and it does not appear to be a good idea to place the
>>>> annotations on the generated classes either. What's the best practice
>>>> for this? Are their teneo properties that replace hibernate properties
>>>> that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want to
>>>> automatically bring that operation back into our ecore, how do we do
>>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>>> a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a single
>>>> table in the legacy database but to 3-4 tables that must be joined.
>>>> How do I indicate this for teneo? This question is related to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>>> to these questions.
>>>
>
Re: [Teneo] legacy database and hibernate mappings [message #134989 is a reply to message #134937] Sun, 12 April 2009 19:24 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Thanks. Just to let you know of progress, I am generating models and
persisting them in hibernate. I believe the EMF approach allows me to
satisfy the change management requirements I have for the core data model.

One thing I have found is that adding annotations to have the generated
ecore model match my legacy database is proving extremely tricky as I
need to search across persistence options as well as ensure I have added
the appropriate JPA annotations in all the right places. One thing that
I did not count on is that teneo is working hard to persist many aspects
of the EMF model...many more features than my legacy database has. These
comments are based on comparing the teneo HBM to the HibernateTools
generated HBM files and thinking through the objects mapping.

So it appears that I need multiple hibernate/jpa annotations to force
the override that I think is appropriate for my legacy database. At some
point, I am not sure when, it will be easier to create a direct mapping
file and turn off in-memory HBM generation.

One question I have for you is whether teneo allows a combination of HBM
generation and HBM integration much in the same way that hibernate
allows annotations and HBM files to complement and add to each other.

I am not sure how all the teneo users think about this and whether they
have the same legacy database change management constraints that I have.
I'll throw out a thought that a small guide on the teneo website
describing the legacy database usecase and accompanying advice may be
helpful to some like myself.


I think I have worked through my ecorediag issues where etypes and
opposite relationships seemed to get corrupted from time to time.



Martin Taal wrote:
> Hi apdev,
> See comments inline marked with MT>>
>
> gr. Martin
>
> aappddeevv wrote:
>> Martin Taal wrote:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate
>>> xml file. This is described here: http://www.elver.org (is this what
>>> you mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if
>>> that is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>
>> Based on your comments, since I am starting with an ecore model
>> (instead of an XSD or annotated java class), it appears that I need to
>> add teneo annotations to the ecore model (which I can do through the
>> diagram interface).
>>
>> If I use this approach, is there a teneo.hibernate corresponding to
>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>> hibernate.
> MT>> The annotations in the model are all JPA (so you should use
> teneo.jpa) with support for some hibernate specific annotations. At
> runtime you can choose to initialize the datastore for standard
> hibernate (the default: HbSessionDataStore) or want to use Hibernate
> Entity Manager (HbEntityDataStore). In your case you should use the
> HbSessionDataStore. So only when defining the annotations in the model
> you should know JPA (the annotations), at runtime you can use classic
> Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).
>
>>
>> Can I also assume that once I generate the java classes, I can
>> initialize my HbDataStore using the factory and the hibernate
>> annotations will be passed along properly to the underlying hibernate
>> engine? It looks like from experiments that the generated java classes
>> do not have the annotations itself.
> MT>> Correct, based on the annotations and the model itself, Teneo
> generates a hbm in-memory and passes this on to hibernate at startup.
> You can find the hbm when calling the method getMappingXML on the
> datastore.
>
>>
>> Is this right?
>>
>>
>>> I think Ed can answer question b better than I do, I would say model
>>> the same operation in ecore and generate from there, but maybe there
>>> are better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>> put on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database.
>>>> The relationships between tables is not 100% well-defined. In some
>>>> places the relationships exist, in others they must be enforced
>>>> through the application. Over time, some fields may be added to the
>>>> tables and some tables may be added but that is under a separate
>>>> change management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to
>>>> suit their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and
>>>> generate schema updates in forward modeling but that change cycle is
>>>> not always allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and
>>>> columns directly in the ecore model? Object names and table names do
>>>> not match nor do we want them to (the legacy names are very
>>>> unfriendly)? We also need to add sql queries and other tricks to get
>>>> relationships to work in the objects. We only have an ecore model.
>>>> Typically we model through the ecore diagram tool. There is no XSD
>>>> or annotated java classes to derive from. I have used teneo to
>>>> generate an hbm file but I don't think that this is the right place
>>>> to put the hibernate options and it does not appear to be a good
>>>> idea to place the annotations on the generated classes either.
>>>> What's the best practice for this? Are their teneo properties that
>>>> replace hibernate properties that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want
>>>> to automatically bring that operation back into our ecore, how do we
>>>> do that (merge java domain objects bakc into ecore)? This is not
>>>> strictly a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a
>>>> single table in the legacy database but to 3-4 tables that must be
>>>> joined. How do I indicate this for teneo? This question is related
>>>> to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>> answers to these questions.
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #135000 is a reply to message #134989] Mon, 13 April 2009 06:27 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Apdev,
Here are some options (with their values) which can turn of some of the EMF features:
PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
PersistenceOptions.ALWAYS_VERSION --> false
PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false

There is one tricky EMF feature called featuremap which is hard to map manually to an existing database structure. It is
for sure possible that you don't have featuremaps in your model..., but if you have then I think you have to change your
model.

Let me know if you encounter any special legacy mapping (with annotations) which is a lot of manual work but could be
handled by an option.

gr. Martin

aappddeevv wrote:
> Thanks. Just to let you know of progress, I am generating models and
> persisting them in hibernate. I believe the EMF approach allows me to
> satisfy the change management requirements I have for the core data model.
>
> One thing I have found is that adding annotations to have the generated
> ecore model match my legacy database is proving extremely tricky as I
> need to search across persistence options as well as ensure I have added
> the appropriate JPA annotations in all the right places. One thing that
> I did not count on is that teneo is working hard to persist many aspects
> of the EMF model...many more features than my legacy database has. These
> comments are based on comparing the teneo HBM to the HibernateTools
> generated HBM files and thinking through the objects mapping.
>
> So it appears that I need multiple hibernate/jpa annotations to force
> the override that I think is appropriate for my legacy database. At some
> point, I am not sure when, it will be easier to create a direct mapping
> file and turn off in-memory HBM generation.
>
> One question I have for you is whether teneo allows a combination of HBM
> generation and HBM integration much in the same way that hibernate
> allows annotations and HBM files to complement and add to each other.
>
> I am not sure how all the teneo users think about this and whether they
> have the same legacy database change management constraints that I have.
> I'll throw out a thought that a small guide on the teneo website
> describing the legacy database usecase and accompanying advice may be
> helpful to some like myself.
>
>
> I think I have worked through my ecorediag issues where etypes and
> opposite relationships seemed to get corrupted from time to time.
>
>
>
> Martin Taal wrote:
>> Hi apdev,
>> See comments inline marked with MT>>
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> Martin Taal wrote:
>>>> Hi apdev,
>>>> With Teneo you can accomplish most of the mapping issues with
>>>> annotations in the model.Either in the ecore itself or in a separate
>>>> xml file. This is described here: http://www.elver.org (is this what
>>>> you mean with Teneo wiki?).
>>>> For example table and column naming is set using Table and Column
>>>> annotations. You can also implement your own sql naming strategy if
>>>> that is easier:
>>>> http://www.elver.org/hibernate/extensions.html
>>>>
>>>
>>> Based on your comments, since I am starting with an ecore model
>>> (instead of an XSD or annotated java class), it appears that I need
>>> to add teneo annotations to the ecore model (which I can do through the
>>> diagram interface).
>>>
>>> If I use this approach, is there a teneo.hibernate corresponding to
>>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>>> hibernate.
>> MT>> The annotations in the model are all JPA (so you should use
>> teneo.jpa) with support for some hibernate specific annotations. At
>> runtime you can choose to initialize the datastore for standard
>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>> Entity Manager (HbEntityDataStore). In your case you should use the
>> HbSessionDataStore. So only when defining the annotations in the model
>> you should know JPA (the annotations), at runtime you can use classic
>> Hibernate. Teneo translates the model JPA annotations to a hbm
>> (in-memory).
>>
>>>
>>> Can I also assume that once I generate the java classes, I can
>>> initialize my HbDataStore using the factory and the hibernate
>>> annotations will be passed along properly to the underlying hibernate
>>> engine? It looks like from experiments that the generated java
>>> classes do not have the annotations itself.
>> MT>> Correct, based on the annotations and the model itself, Teneo
>> generates a hbm in-memory and passes this on to hibernate at startup.
>> You can find the hbm when calling the method getMappingXML on the
>> datastore.
>>
>>>
>>> Is this right?
>>>
>>>
>>>> I think Ed can answer question b better than I do, I would say model
>>>> the same operation in ecore and generate from there, but maybe there
>>>> are better options.
>>>>
>>>> For question c you can use SecundaryTable annotations.
>>>>
>>>> The supported annotations are listed here:
>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>
>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>> normally easy to add.
>>>>
>>>> Here are examples of annotated models (in ecore and xml):
>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>
>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>> put on the cc).
>>>>
>>>> gr. Martin
>>>>
>>>> aappddeevv wrote:
>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>
>>>>> I would like to use Teneo for hibernate access to legacy database.
>>>>> The relationships between tables is not 100% well-defined. In some
>>>>> places the relationships exist, in others they must be enforced
>>>>> through the application. Over time, some fields may be added to the
>>>>> tables and some tables may be added but that is under a separate
>>>>> change management cycle not solely controlled by our group.
>>>>>
>>>>> I would like to use Teneo so that we can adapt to database changes
>>>>> that we and other groups ask for as well as allow other groups to
>>>>> extend our ecore models and more easily update our application to
>>>>> suit their needs. Essentially they might extend the database and
>>>>> respectively extend the model. I realize that I can model and
>>>>> generate schema updates in forward modeling but that change cycle
>>>>> is not always allowed for the application groups.
>>>>>
>>>>>
>>>>> Questions on some best practices to help with this:
>>>>>
>>>>> a) How do I indicate hibernate options for the table name and
>>>>> columns directly in the ecore model? Object names and table names
>>>>> do not match nor do we want them to (the legacy names are very
>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>> get relationships to work in the objects. We only have an ecore
>>>>> model. Typically we model through the ecore diagram tool. There is
>>>>> no XSD or annotated java classes to derive from. I have used teneo
>>>>> to generate an hbm file but I don't think that this is the right
>>>>> place to put the hibernate options and it does not appear to be a
>>>>> good idea to place the annotations on the generated classes either.
>>>>> What's the best practice for this? Are their teneo properties that
>>>>> replace hibernate properties that I should use instead?
>>>>>
>>>>> b) If someone writes a new method in our domain object and we want
>>>>> to automatically bring that operation back into our ecore, how do
>>>>> we do that (merge java domain objects bakc into ecore)? This is not
>>>>> strictly a teneo question.
>>>>>
>>>>> c) Some objects that we want in our application do not map to a
>>>>> single table in the legacy database but to 3-4 tables that must be
>>>>> joined. How do I indicate this for teneo? This question is related
>>>>> to (1).
>>>>>
>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>> answers to these questions.
>>>>
>>>>
>>
>>


--

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] legacy database and hibernate mappings [message #135012 is a reply to message #135000] Mon, 13 April 2009 15:47 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
I think this is a legacy issue that could be handled by an option. I
have seen the XSD date persistence options but this seems to be another
issue:

a) When creating a datetime field the only EMF options is EDate.
b) The inmemory HBM creates timestamp fields (which is actually what I
want but seems strictly inconsistent with EDate).
c) If you specify one of the EDate fields to be @Version (timestamp
versioning, which is not perfect but that's what the legacy database
has) then the @Version seems to force the field type to
org.eclipse.emf.teneo.hibernate.mapping.XSDDateTime where I really want
type="timestamp". The reasoning would be that @Version marks a java
field which should infer the type (such as timestamp) from the type of
the field.

Perhaps an option that says for version fields that are dates, the type
should be X.


Also,

a) I can't seem to get rid of a generated foreign-key (a FK index
specification) hibernate option on a ManyToOne.
b) Can't seem to force a @Id property to create not-null="true" and
unique=true in the generated HBM automatically. You have to specify it
fully using @Column which does work.


I am sure this can all be handled with the extensions.



Martin Taal wrote:
> Hi Apdev,
> Here are some options (with their values) which can turn of some of the
> EMF features:
> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
> PersistenceOptions.ALWAYS_VERSION --> false
> PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
> PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false
>
> There is one tricky EMF feature called featuremap which is hard to map
> manually to an existing database structure. It is for sure possible that
> you don't have featuremaps in your model..., but if you have then I
> think you have to change your model.
>
> Let me know if you encounter any special legacy mapping (with
> annotations) which is a lot of manual work but could be handled by an
> option.
>
> gr. Martin
>
> aappddeevv wrote:
>> Thanks. Just to let you know of progress, I am generating models and
>> persisting them in hibernate. I believe the EMF approach allows me to
>> satisfy the change management requirements I have for the core data
>> model.
>>
>> One thing I have found is that adding annotations to have the
>> generated ecore model match my legacy database is proving extremely
>> tricky as I need to search across persistence options as well as
>> ensure I have added the appropriate JPA annotations in all the right
>> places. One thing that I did not count on is that teneo is working
>> hard to persist many aspects of the EMF model...many more features
>> than my legacy database has. These comments are based on comparing the
>> teneo HBM to the HibernateTools generated HBM files and thinking
>> through the objects mapping.
>>
>> So it appears that I need multiple hibernate/jpa annotations to force
>> the override that I think is appropriate for my legacy database. At
>> some point, I am not sure when, it will be easier to create a direct
>> mapping file and turn off in-memory HBM generation.
>>
>> One question I have for you is whether teneo allows a combination of
>> HBM generation and HBM integration much in the same way that hibernate
>> allows annotations and HBM files to complement and add to each other.
>>
>> I am not sure how all the teneo users think about this and whether
>> they have the same legacy database change management constraints that
>> I have. I'll throw out a thought that a small guide on the teneo
>> website describing the legacy database usecase and accompanying advice
>> may be helpful to some like myself.
>>
>>
>> I think I have worked through my ecorediag issues where etypes and
>> opposite relationships seemed to get corrupted from time to time.
>>
>>
>>
>> Martin Taal wrote:
>>> Hi apdev,
>>> See comments inline marked with MT>>
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> Martin Taal wrote:
>>>>> Hi apdev,
>>>>> With Teneo you can accomplish most of the mapping issues with
>>>>> annotations in the model.Either in the ecore itself or in a
>>>>> separate xml file. This is described here: http://www.elver.org (is
>>>>> this what you mean with Teneo wiki?).
>>>>> For example table and column naming is set using Table and Column
>>>>> annotations. You can also implement your own sql naming strategy if
>>>>> that is easier:
>>>>> http://www.elver.org/hibernate/extensions.html
>>>>>
>>>>
>>>> Based on your comments, since I am starting with an ecore model
>>>> (instead of an XSD or annotated java class), it appears that I need
>>>> to add teneo annotations to the ecore model (which I can do through the
>>>> diagram interface).
>>>>
>>>> If I use this approach, is there a teneo.hibernate corresponding to
>>>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>>>> hibernate.
>>> MT>> The annotations in the model are all JPA (so you should use
>>> teneo.jpa) with support for some hibernate specific annotations. At
>>> runtime you can choose to initialize the datastore for standard
>>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>>> Entity Manager (HbEntityDataStore). In your case you should use the
>>> HbSessionDataStore. So only when defining the annotations in the
>>> model you should know JPA (the annotations), at runtime you can use
>>> classic Hibernate. Teneo translates the model JPA annotations to a
>>> hbm (in-memory).
>>>
>>>>
>>>> Can I also assume that once I generate the java classes, I can
>>>> initialize my HbDataStore using the factory and the hibernate
>>>> annotations will be passed along properly to the underlying
>>>> hibernate engine? It looks like from experiments that the generated
>>>> java classes do not have the annotations itself.
>>> MT>> Correct, based on the annotations and the model itself, Teneo
>>> generates a hbm in-memory and passes this on to hibernate at startup.
>>> You can find the hbm when calling the method getMappingXML on the
>>> datastore.
>>>
>>>>
>>>> Is this right?
>>>>
>>>>
>>>>> I think Ed can answer question b better than I do, I would say
>>>>> model the same operation in ecore and generate from there, but
>>>>> maybe there are better options.
>>>>>
>>>>> For question c you can use SecundaryTable annotations.
>>>>>
>>>>> The supported annotations are listed here:
>>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>>
>>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>>> normally easy to add.
>>>>>
>>>>> Here are examples of annotated models (in ecore and xml):
>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>
>>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>>> put on the cc).
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> aappddeevv wrote:
>>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>>
>>>>>> I would like to use Teneo for hibernate access to legacy database.
>>>>>> The relationships between tables is not 100% well-defined. In some
>>>>>> places the relationships exist, in others they must be enforced
>>>>>> through the application. Over time, some fields may be added to
>>>>>> the tables and some tables may be added but that is under a
>>>>>> separate change management cycle not solely controlled by our group.
>>>>>>
>>>>>> I would like to use Teneo so that we can adapt to database changes
>>>>>> that we and other groups ask for as well as allow other groups to
>>>>>> extend our ecore models and more easily update our application to
>>>>>> suit their needs. Essentially they might extend the database and
>>>>>> respectively extend the model. I realize that I can model and
>>>>>> generate schema updates in forward modeling but that change cycle
>>>>>> is not always allowed for the application groups.
>>>>>>
>>>>>>
>>>>>> Questions on some best practices to help with this:
>>>>>>
>>>>>> a) How do I indicate hibernate options for the table name and
>>>>>> columns directly in the ecore model? Object names and table names
>>>>>> do not match nor do we want them to (the legacy names are very
>>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>>> get relationships to work in the objects. We only have an ecore
>>>>>> model. Typically we model through the ecore diagram tool. There
>>>>>> is no XSD or annotated java classes to derive from. I have used
>>>>>> teneo to generate an hbm file but I don't think that this is the
>>>>>> right place to put the hibernate options and it does not appear to
>>>>>> be a good idea to place the annotations on the generated classes
>>>>>> either. What's the best practice for this? Are their teneo
>>>>>> properties that replace hibernate properties that I should use
>>>>>> instead?
>>>>>>
>>>>>> b) If someone writes a new method in our domain object and we want
>>>>>> to automatically bring that operation back into our ecore, how do
>>>>>> we do that (merge java domain objects bakc into ecore)? This is
>>>>>> not strictly a teneo question.
>>>>>>
>>>>>> c) Some objects that we want in our application do not map to a
>>>>>> single table in the legacy database but to 3-4 tables that must be
>>>>>> joined. How do I indicate this for teneo? This question is related
>>>>>> to (1).
>>>>>>
>>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>>> answers to these questions.
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #135026 is a reply to message #135012] Mon, 13 April 2009 19:31 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I answered this post on the EMF newsgroup.

gr. Martin

aappddeevv wrote:
> I think this is a legacy issue that could be handled by an option. I
> have seen the XSD date persistence options but this seems to be another
> issue:
>
> a) When creating a datetime field the only EMF options is EDate.
> b) The inmemory HBM creates timestamp fields (which is actually what I
> want but seems strictly inconsistent with EDate).
> c) If you specify one of the EDate fields to be @Version (timestamp
> versioning, which is not perfect but that's what the legacy database
> has) then the @Version seems to force the field type to
> org.eclipse.emf.teneo.hibernate.mapping.XSDDateTime where I really want
> type="timestamp". The reasoning would be that @Version marks a java
> field which should infer the type (such as timestamp) from the type of
> the field.
>
> Perhaps an option that says for version fields that are dates, the type
> should be X.
>
>
> Also,
>
> a) I can't seem to get rid of a generated foreign-key (a FK index
> specification) hibernate option on a ManyToOne.
> b) Can't seem to force a @Id property to create not-null="true" and
> unique=true in the generated HBM automatically. You have to specify it
> fully using @Column which does work.
>
>
> I am sure this can all be handled with the extensions.
>
>
>
> Martin Taal wrote:
>> Hi Apdev,
>> Here are some options (with their values) which can turn of some of
>> the EMF features:
>> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
>> PersistenceOptions.ALWAYS_VERSION --> false
>> PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
>> PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false
>>
>> There is one tricky EMF feature called featuremap which is hard to map
>> manually to an existing database structure. It is for sure possible
>> that you don't have featuremaps in your model..., but if you have then
>> I think you have to change your model.
>>
>> Let me know if you encounter any special legacy mapping (with
>> annotations) which is a lot of manual work but could be handled by an
>> option.
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> Thanks. Just to let you know of progress, I am generating models and
>>> persisting them in hibernate. I believe the EMF approach allows me to
>>> satisfy the change management requirements I have for the core data
>>> model.
>>>
>>> One thing I have found is that adding annotations to have the
>>> generated ecore model match my legacy database is proving extremely
>>> tricky as I need to search across persistence options as well as
>>> ensure I have added the appropriate JPA annotations in all the right
>>> places. One thing that I did not count on is that teneo is working
>>> hard to persist many aspects of the EMF model...many more features
>>> than my legacy database has. These comments are based on comparing
>>> the teneo HBM to the HibernateTools generated HBM files and thinking
>>> through the objects mapping.
>>>
>>> So it appears that I need multiple hibernate/jpa annotations to force
>>> the override that I think is appropriate for my legacy database. At
>>> some point, I am not sure when, it will be easier to create a direct
>>> mapping file and turn off in-memory HBM generation.
>>>
>>> One question I have for you is whether teneo allows a combination of
>>> HBM generation and HBM integration much in the same way that
>>> hibernate allows annotations and HBM files to complement and add to
>>> each other.
>>>
>>> I am not sure how all the teneo users think about this and whether
>>> they have the same legacy database change management constraints that
>>> I have. I'll throw out a thought that a small guide on the teneo
>>> website describing the legacy database usecase and accompanying
>>> advice may be helpful to some like myself.
>>>
>>>
>>> I think I have worked through my ecorediag issues where etypes and
>>> opposite relationships seemed to get corrupted from time to time.
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi apdev,
>>>> See comments inline marked with MT>>
>>>>
>>>> gr. Martin
>>>>
>>>> aappddeevv wrote:
>>>>> Martin Taal wrote:
>>>>>> Hi apdev,
>>>>>> With Teneo you can accomplish most of the mapping issues with
>>>>>> annotations in the model.Either in the ecore itself or in a
>>>>>> separate xml file. This is described here: http://www.elver.org
>>>>>> (is this what you mean with Teneo wiki?).
>>>>>> For example table and column naming is set using Table and Column
>>>>>> annotations. You can also implement your own sql naming strategy
>>>>>> if that is easier:
>>>>>> http://www.elver.org/hibernate/extensions.html
>>>>>>
>>>>>
>>>>> Based on your comments, since I am starting with an ecore model
>>>>> (instead of an XSD or annotated java class), it appears that I need
>>>>> to add teneo annotations to the ecore model (which I can do through
>>>>> the
>>>>> diagram interface).
>>>>>
>>>>> If I use this approach, is there a teneo.hibernate corresponding to
>>>>> the teneo.jpa that I should use? I don't use any of the JPA parts
>>>>> of hibernate.
>>>> MT>> The annotations in the model are all JPA (so you should use
>>>> teneo.jpa) with support for some hibernate specific annotations. At
>>>> runtime you can choose to initialize the datastore for standard
>>>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>>>> Entity Manager (HbEntityDataStore). In your case you should use the
>>>> HbSessionDataStore. So only when defining the annotations in the
>>>> model you should know JPA (the annotations), at runtime you can use
>>>> classic Hibernate. Teneo translates the model JPA annotations to a
>>>> hbm (in-memory).
>>>>
>>>>>
>>>>> Can I also assume that once I generate the java classes, I can
>>>>> initialize my HbDataStore using the factory and the hibernate
>>>>> annotations will be passed along properly to the underlying
>>>>> hibernate engine? It looks like from experiments that the generated
>>>>> java classes do not have the annotations itself.
>>>> MT>> Correct, based on the annotations and the model itself, Teneo
>>>> generates a hbm in-memory and passes this on to hibernate at
>>>> startup. You can find the hbm when calling the method getMappingXML
>>>> on the datastore.
>>>>
>>>>>
>>>>> Is this right?
>>>>>
>>>>>
>>>>>> I think Ed can answer question b better than I do, I would say
>>>>>> model the same operation in ecore and generate from there, but
>>>>>> maybe there are better options.
>>>>>>
>>>>>> For question c you can use SecundaryTable annotations.
>>>>>>
>>>>>> The supported annotations are listed here:
>>>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>>>
>>>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>>>> normally easy to add.
>>>>>>
>>>>>> Here are examples of annotated models (in ecore and xml):
>>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>>
>>>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>>>> put on the cc).
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> aappddeevv wrote:
>>>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>>>
>>>>>>> I would like to use Teneo for hibernate access to legacy
>>>>>>> database. The relationships between tables is not 100%
>>>>>>> well-defined. In some places the relationships exist, in others
>>>>>>> they must be enforced through the application. Over time, some
>>>>>>> fields may be added to the tables and some tables may be added
>>>>>>> but that is under a separate change management cycle not solely
>>>>>>> controlled by our group.
>>>>>>>
>>>>>>> I would like to use Teneo so that we can adapt to database
>>>>>>> changes that we and other groups ask for as well as allow other
>>>>>>> groups to extend our ecore models and more easily update our
>>>>>>> application to suit their needs. Essentially they might extend
>>>>>>> the database and respectively extend the model. I realize that I
>>>>>>> can model and generate schema updates in forward modeling but
>>>>>>> that change cycle is not always allowed for the application groups.
>>>>>>>
>>>>>>>
>>>>>>> Questions on some best practices to help with this:
>>>>>>>
>>>>>>> a) How do I indicate hibernate options for the table name and
>>>>>>> columns directly in the ecore model? Object names and table names
>>>>>>> do not match nor do we want them to (the legacy names are very
>>>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>>>> get relationships to work in the objects. We only have an ecore
>>>>>>> model. Typically we model through the ecore diagram tool. There
>>>>>>> is no XSD or annotated java classes to derive from. I have used
>>>>>>> teneo to generate an hbm file but I don't think that this is the
>>>>>>> right place to put the hibernate options and it does not appear
>>>>>>> to be a good idea to place the annotations on the generated
>>>>>>> classes either. What's the best practice for this? Are their
>>>>>>> teneo properties that replace hibernate properties that I should
>>>>>>> use instead?
>>>>>>>
>>>>>>> b) If someone writes a new method in our domain object and we
>>>>>>> want to automatically bring that operation back into our ecore,
>>>>>>> how do we do that (merge java domain objects bakc into ecore)?
>>>>>>> This is not strictly a teneo question.
>>>>>>>
>>>>>>> c) Some objects that we want in our application do not map to a
>>>>>>> single table in the legacy database but to 3-4 tables that must
>>>>>>> be joined. How do I indicate this for teneo? This question is
>>>>>>> related to (1).
>>>>>>>
>>>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>>>> answers to these questions.
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

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] legacy database and hibernate mappings [message #620794 is a reply to message #134859] Fri, 10 April 2009 21:34 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi apdev,
With Teneo you can accomplish most of the mapping issues with annotations in the model.Either in the ecore itself or in
a separate xml file. This is described here: http://www.elver.org (is this what you mean with Teneo wiki?).
For example table and column naming is set using Table and Column annotations. You can also implement your own sql
naming strategy if that is easier:
http://www.elver.org/hibernate/extensions.html

I think Ed can answer question b better than I do, I would say model the same operation in ecore and generate from
there, but maybe there are better options.

For question c you can use SecundaryTable annotations.

The supported annotations are listed here:
http://www.elver.org/hibernate/ejb3_features.html

Let me know if you miss a hibernate-specific annotation, they are normally easy to add.

Here are examples of annotated models (in ecore and xml):
http://www.elver.org/hibernate/ejb3_examples.html

btw, support for Teneo is given on the main EMF newsgroup (which I put on the cc).

gr. Martin

aappddeevv wrote:
> EMF+Teneo+Hibernate+Spring+RCP
>
> I would like to use Teneo for hibernate access to legacy database. The
> relationships between tables is not 100% well-defined. In some places
> the relationships exist, in others they must be enforced through the
> application. Over time, some fields may be added to the tables and some
> tables may be added but that is under a separate change management cycle
> not solely controlled by our group.
>
> I would like to use Teneo so that we can adapt to database changes that
> we and other groups ask for as well as allow other groups to extend our
> ecore models and more easily update our application to suit their needs.
> Essentially they might extend the database and respectively extend the
> model. I realize that I can model and generate schema updates in forward
> modeling but that change cycle is not always allowed for the application
> groups.
>
>
> Questions on some best practices to help with this:
>
> a) How do I indicate hibernate options for the table name and columns
> directly in the ecore model? Object names and table names do not match
> nor do we want them to (the legacy names are very unfriendly)? We also
> need to add sql queries and other tricks to get relationships to work in
> the objects. We only have an ecore model. Typically we model through the
> ecore diagram tool. There is no XSD or annotated java classes to derive
> from. I have used teneo to generate an hbm file but I don't think that
> this is the right place to put the hibernate options and it does not
> appear to be a good idea to place the annotations on the generated
> classes either. What's the best practice for this? Are their teneo
> properties that replace hibernate properties that I should use instead?
>
> b) If someone writes a new method in our domain object and we want to
> automatically bring that operation back into our ecore, how do we do
> that (merge java domain objects bakc into ecore)? This is not strictly a
> teneo question.
>
> c) Some objects that we want in our application do not map to a single
> table in the legacy database but to 3-4 tables that must be joined. How
> do I indicate this for teneo? This question is related to (1).
>
> I've read through the teneo wiki but am not sure I saw obvious answers
> to these questions.


--

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] legacy database and hibernate mappings [message #620795 is a reply to message #134872] Fri, 10 April 2009 21:56 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Before you decide to use Teneo for your *RCP* application I think that
you might reconsider it. Teneo inherits the hibernate "problem" that it
is created for short time transactions and is not really useable for
long term concurrency (at least this is my way of thinking).

So if you have multiple people are using your application at the same
time you'll maybe run into trouble. IMHO the combination of Teneo and
CDO is unbeatable for such a scenario though don't know the current
state of the CDO-Teneo backend.

Tom

Martin Taal schrieb:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>
> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620796 is a reply to message #134872] Fri, 10 April 2009 23:31 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Martin Taal wrote:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>

Based on your comments, since I am starting with an ecore model (instead
of an XSD or annotated java class), it appears that I need to add teneo
annotations to the ecore model (which I can do through the
diagram interface).

If I use this approach, is there a teneo.hibernate corresponding to the
teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.

Can I also assume that once I generate the java classes, I can
initialize my HbDataStore using the factory and the hibernate
annotations will be passed along properly to the underlying hibernate
engine? It looks like from experiments that the generated java classes
do not have the annotations itself.

Is this right?


> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620798 is a reply to message #134872] Fri, 10 April 2009 23:32 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Martin Taal wrote:
> Hi apdev,
> With Teneo you can accomplish most of the mapping issues with
> annotations in the model.Either in the ecore itself or in a separate xml
> file. This is described here: http://www.elver.org (is this what you
> mean with Teneo wiki?).
> For example table and column naming is set using Table and Column
> annotations. You can also implement your own sql naming strategy if that
> is easier:
> http://www.elver.org/hibernate/extensions.html
>

Based on your comments, since I am starting with an ecore model (instead
of an XSD or annotated java class), it appears that I need to add teneo
annotations to the ecore model (which I can do through the
diagram interface).

If I use this approach, is there a teneo.hibernate corresponding to the
teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.

Can I also assume that once I generate the java classes, I can
initialize my HbDataStore using the factory and the hibernate
annotations will be passed along properly to the underlying hibernate
engine? It looks like from experiments that the generated java classes
do not have the annotations itself.

Is this right?


> I think Ed can answer question b better than I do, I would say model the
> same operation in ecore and generate from there, but maybe there are
> better options.
>
> For question c you can use SecundaryTable annotations.
>
> The supported annotations are listed here:
> http://www.elver.org/hibernate/ejb3_features.html
>
> Let me know if you miss a hibernate-specific annotation, they are
> normally easy to add.
>
> Here are examples of annotated models (in ecore and xml):
> http://www.elver.org/hibernate/ejb3_examples.html
>
> btw, support for Teneo is given on the main EMF newsgroup (which I put
> on the cc).
>
> gr. Martin
>
> aappddeevv wrote:
>> EMF+Teneo+Hibernate+Spring+RCP
>>
>> I would like to use Teneo for hibernate access to legacy database. The
>> relationships between tables is not 100% well-defined. In some places
>> the relationships exist, in others they must be enforced through the
>> application. Over time, some fields may be added to the tables and
>> some tables may be added but that is under a separate change
>> management cycle not solely controlled by our group.
>>
>> I would like to use Teneo so that we can adapt to database changes
>> that we and other groups ask for as well as allow other groups to
>> extend our ecore models and more easily update our application to suit
>> their needs. Essentially they might extend the database and
>> respectively extend the model. I realize that I can model and generate
>> schema updates in forward modeling but that change cycle is not always
>> allowed for the application groups.
>>
>>
>> Questions on some best practices to help with this:
>>
>> a) How do I indicate hibernate options for the table name and columns
>> directly in the ecore model? Object names and table names do not match
>> nor do we want them to (the legacy names are very unfriendly)? We also
>> need to add sql queries and other tricks to get relationships to work
>> in the objects. We only have an ecore model. Typically we model
>> through the ecore diagram tool. There is no XSD or annotated java
>> classes to derive from. I have used teneo to generate an hbm file but
>> I don't think that this is the right place to put the hibernate
>> options and it does not appear to be a good idea to place the
>> annotations on the generated classes either. What's the best practice
>> for this? Are their teneo properties that replace hibernate properties
>> that I should use instead?
>>
>> b) If someone writes a new method in our domain object and we want to
>> automatically bring that operation back into our ecore, how do we do
>> that (merge java domain objects bakc into ecore)? This is not strictly
>> a teneo question.
>>
>> c) Some objects that we want in our application do not map to a single
>> table in the legacy database but to 3-4 tables that must be joined.
>> How do I indicate this for teneo? This question is related to (1).
>>
>> I've read through the teneo wiki but am not sure I saw obvious answers
>> to these questions.
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620800 is a reply to message #134885] Fri, 10 April 2009 23:32 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Tom,
Regarding long transactions. A Hibernate session can be kept open indefinitely while you use multiple transactions (over
time) to read extra data. Then at a certain point in time you can flush the state of the session to the database. This
is also the mode used in Seam to support conversations over multiple (http) requests.
I fully understand that this is only a small part of the long term concurrency story but still wanted to mention it for
the record.

For the rest I fully agree that CDO itself and the combination of CDO/Teneo is a very good solution for a RCP. Teneo
standalone is more server oriented (for example in case of webservices, or when server side logic is an important part
of the solution). Also when you need (HQL) querying or need practically full support of all EMF/XSD model constructs
then Teneo is a good solution.

Regarding the CDO/Teneo backend, currently 33 of the around 390 testcases fail. I hope to spend a few hours per week on
this.

gr. Martin

Tom Schindl wrote:
> Hi,
>
> Before you decide to use Teneo for your *RCP* application I think that
> you might reconsider it. Teneo inherits the hibernate "problem" that it
> is created for short time transactions and is not really useable for
> long term concurrency (at least this is my way of thinking).
>
> So if you have multiple people are using your application at the same
> time you'll maybe run into trouble. IMHO the combination of Teneo and
> CDO is unbeatable for such a scenario though don't know the current
> state of the CDO-Teneo backend.
>
> Tom
>
> Martin Taal schrieb:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate xml
>> file. This is described here: http://www.elver.org (is this what you
>> mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if that
>> is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>> I think Ed can answer question b better than I do, I would say model the
>> same operation in ecore and generate from there, but maybe there are
>> better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database. The
>>> relationships between tables is not 100% well-defined. In some places
>>> the relationships exist, in others they must be enforced through the
>>> application. Over time, some fields may be added to the tables and
>>> some tables may be added but that is under a separate change
>>> management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to suit
>>> their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and generate
>>> schema updates in forward modeling but that change cycle is not always
>>> allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not match
>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>> need to add sql queries and other tricks to get relationships to work
>>> in the objects. We only have an ecore model. Typically we model
>>> through the ecore diagram tool. There is no XSD or annotated java
>>> classes to derive from. I have used teneo to generate an hbm file but
>>> I don't think that this is the right place to put the hibernate
>>> options and it does not appear to be a good idea to place the
>>> annotations on the generated classes either. What's the best practice
>>> for this? Are their teneo properties that replace hibernate properties
>>> that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>> a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a single
>>> table in the legacy database but to 3-4 tables that must be joined.
>>> How do I indicate this for teneo? This question is related to (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>> to these questions.
>>


--

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] legacy database and hibernate mappings [message #620802 is a reply to message #134911] Fri, 10 April 2009 23:40 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi apdev,
See comments inline marked with MT>>

gr. Martin

aappddeevv wrote:
> Martin Taal wrote:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate
>> xml file. This is described here: http://www.elver.org (is this what
>> you mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if
>> that is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>
> Based on your comments, since I am starting with an ecore model (instead
> of an XSD or annotated java class), it appears that I need to add teneo
> annotations to the ecore model (which I can do through the
> diagram interface).
>
> If I use this approach, is there a teneo.hibernate corresponding to the
> teneo.jpa that I should use? I don't use any of the JPA parts of hibernate.
MT>> The annotations in the model are all JPA (so you should use teneo.jpa) with support for some hibernate specific
annotations. At runtime you can choose to initialize the datastore for standard hibernate (the default:
HbSessionDataStore) or want to use Hibernate Entity Manager (HbEntityDataStore). In your case you should use the
HbSessionDataStore. So only when defining the annotations in the model you should know JPA (the annotations), at runtime
you can use classic Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).

>
> Can I also assume that once I generate the java classes, I can
> initialize my HbDataStore using the factory and the hibernate
> annotations will be passed along properly to the underlying hibernate
> engine? It looks like from experiments that the generated java classes
> do not have the annotations itself.
MT>> Correct, based on the annotations and the model itself, Teneo generates a hbm in-memory and passes this on to
hibernate at startup. You can find the hbm when calling the method getMappingXML on the datastore.

>
> Is this right?
>
>
>> I think Ed can answer question b better than I do, I would say model
>> the same operation in ecore and generate from there, but maybe there
>> are better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database.
>>> The relationships between tables is not 100% well-defined. In some
>>> places the relationships exist, in others they must be enforced
>>> through the application. Over time, some fields may be added to the
>>> tables and some tables may be added but that is under a separate
>>> change management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to
>>> suit their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and
>>> generate schema updates in forward modeling but that change cycle is
>>> not always allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not
>>> match nor do we want them to (the legacy names are very unfriendly)?
>>> We also need to add sql queries and other tricks to get relationships
>>> to work in the objects. We only have an ecore model. Typically we
>>> model through the ecore diagram tool. There is no XSD or annotated
>>> java classes to derive from. I have used teneo to generate an hbm
>>> file but I don't think that this is the right place to put the
>>> hibernate options and it does not appear to be a good idea to place
>>> the annotations on the generated classes either. What's the best
>>> practice for this? Are their teneo properties that replace hibernate
>>> properties that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not
>>> strictly a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a
>>> single table in the legacy database but to 3-4 tables that must be
>>> joined. How do I indicate this for teneo? This question is related to
>>> (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious
>>> answers to these questions.
>>
>>


--

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] legacy database and hibernate mappings [message #620804 is a reply to message #134885] Sat, 11 April 2009 00:33 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Tom Schindl wrote:
> Hi,
>
> Before you decide to use Teneo for your *RCP* application I think that
> you might reconsider it. Teneo inherits the hibernate "problem" that it
> is created for short time transactions and is not really useable for
> long term concurrency (at least this is my way of thinking).
>

Yes. I looked into this issue over a long period of time and blogged a
bunch of thoughts. For RCP when using spring (which I like) I found that
I needed to use the orchestra long session scope (its a pacakge off of
the myfaces package) that intercepts all methods and swaps in the proper
session before the method call. This makes the rest of spring behave
consistently. Of course, you can just hold onto the session object and
not use spring transactions. There no easy conversation/session
management like in jboss's seam for RCP.

I have not found any good material on session management for RCP
applications except that for some "editors" a long session is a must and
for high latency connections, a long session is needed as well. To be
honest, I have found that it takes alot of skill to balance session
lifetime, lazy loading and units of work.

I have looked at CDO but could not determine enough about it to
understand session management. I liked the concept though and thought
the wiki documentation was a good start. All together, EMF, teneo and
CDO is quite an impressive stack.

Tom, since I believe you have good insights I will look into CDO again
especially around conversations.




> So if you have multiple people are using your application at the same
> time you'll maybe run into trouble. IMHO the combination of Teneo and
> CDO is unbeatable for such a scenario though don't know the current
> state of the CDO-Teneo backend.
>
> Tom
>
> Martin Taal schrieb:
>> Hi apdev,
>> With Teneo you can accomplish most of the mapping issues with
>> annotations in the model.Either in the ecore itself or in a separate xml
>> file. This is described here: http://www.elver.org (is this what you
>> mean with Teneo wiki?).
>> For example table and column naming is set using Table and Column
>> annotations. You can also implement your own sql naming strategy if that
>> is easier:
>> http://www.elver.org/hibernate/extensions.html
>>
>> I think Ed can answer question b better than I do, I would say model the
>> same operation in ecore and generate from there, but maybe there are
>> better options.
>>
>> For question c you can use SecundaryTable annotations.
>>
>> The supported annotations are listed here:
>> http://www.elver.org/hibernate/ejb3_features.html
>>
>> Let me know if you miss a hibernate-specific annotation, they are
>> normally easy to add.
>>
>> Here are examples of annotated models (in ecore and xml):
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>> on the cc).
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> EMF+Teneo+Hibernate+Spring+RCP
>>>
>>> I would like to use Teneo for hibernate access to legacy database. The
>>> relationships between tables is not 100% well-defined. In some places
>>> the relationships exist, in others they must be enforced through the
>>> application. Over time, some fields may be added to the tables and
>>> some tables may be added but that is under a separate change
>>> management cycle not solely controlled by our group.
>>>
>>> I would like to use Teneo so that we can adapt to database changes
>>> that we and other groups ask for as well as allow other groups to
>>> extend our ecore models and more easily update our application to suit
>>> their needs. Essentially they might extend the database and
>>> respectively extend the model. I realize that I can model and generate
>>> schema updates in forward modeling but that change cycle is not always
>>> allowed for the application groups.
>>>
>>>
>>> Questions on some best practices to help with this:
>>>
>>> a) How do I indicate hibernate options for the table name and columns
>>> directly in the ecore model? Object names and table names do not match
>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>> need to add sql queries and other tricks to get relationships to work
>>> in the objects. We only have an ecore model. Typically we model
>>> through the ecore diagram tool. There is no XSD or annotated java
>>> classes to derive from. I have used teneo to generate an hbm file but
>>> I don't think that this is the right place to put the hibernate
>>> options and it does not appear to be a good idea to place the
>>> annotations on the generated classes either. What's the best practice
>>> for this? Are their teneo properties that replace hibernate properties
>>> that I should use instead?
>>>
>>> b) If someone writes a new method in our domain object and we want to
>>> automatically bring that operation back into our ecore, how do we do
>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>> a teneo question.
>>>
>>> c) Some objects that we want in our application do not map to a single
>>> table in the legacy database but to 3-4 tables that must be joined.
>>> How do I indicate this for teneo? This question is related to (1).
>>>
>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>> to these questions.
>>
Re: [Teneo] legacy database and hibernate mappings [message #620807 is a reply to message #134937] Sat, 11 April 2009 00:39 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Thanks. I believe this answers this first question.

Now if I can just figure out the diagramming tool a bit more I should be
in good shape :-)



Martin Taal wrote:
> Hi apdev,
> See comments inline marked with MT>>
>
> gr. Martin
>
> aappddeevv wrote:
>> Martin Taal wrote:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate
>>> xml file. This is described here: http://www.elver.org (is this what
>>> you mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if
>>> that is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>
>> Based on your comments, since I am starting with an ecore model
>> (instead of an XSD or annotated java class), it appears that I need to
>> add teneo annotations to the ecore model (which I can do through the
>> diagram interface).
>>
>> If I use this approach, is there a teneo.hibernate corresponding to
>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>> hibernate.
> MT>> The annotations in the model are all JPA (so you should use
> teneo.jpa) with support for some hibernate specific annotations. At
> runtime you can choose to initialize the datastore for standard
> hibernate (the default: HbSessionDataStore) or want to use Hibernate
> Entity Manager (HbEntityDataStore). In your case you should use the
> HbSessionDataStore. So only when defining the annotations in the model
> you should know JPA (the annotations), at runtime you can use classic
> Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).
>
>>
>> Can I also assume that once I generate the java classes, I can
>> initialize my HbDataStore using the factory and the hibernate
>> annotations will be passed along properly to the underlying hibernate
>> engine? It looks like from experiments that the generated java classes
>> do not have the annotations itself.
> MT>> Correct, based on the annotations and the model itself, Teneo
> generates a hbm in-memory and passes this on to hibernate at startup.
> You can find the hbm when calling the method getMappingXML on the
> datastore.
>
>>
>> Is this right?
>>
>>
>>> I think Ed can answer question b better than I do, I would say model
>>> the same operation in ecore and generate from there, but maybe there
>>> are better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>> put on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database.
>>>> The relationships between tables is not 100% well-defined. In some
>>>> places the relationships exist, in others they must be enforced
>>>> through the application. Over time, some fields may be added to the
>>>> tables and some tables may be added but that is under a separate
>>>> change management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to
>>>> suit their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and
>>>> generate schema updates in forward modeling but that change cycle is
>>>> not always allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and
>>>> columns directly in the ecore model? Object names and table names do
>>>> not match nor do we want them to (the legacy names are very
>>>> unfriendly)? We also need to add sql queries and other tricks to get
>>>> relationships to work in the objects. We only have an ecore model.
>>>> Typically we model through the ecore diagram tool. There is no XSD
>>>> or annotated java classes to derive from. I have used teneo to
>>>> generate an hbm file but I don't think that this is the right place
>>>> to put the hibernate options and it does not appear to be a good
>>>> idea to place the annotations on the generated classes either.
>>>> What's the best practice for this? Are their teneo properties that
>>>> replace hibernate properties that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want
>>>> to automatically bring that operation back into our ecore, how do we
>>>> do that (merge java domain objects bakc into ecore)? This is not
>>>> strictly a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a
>>>> single table in the legacy database but to 3-4 tables that must be
>>>> joined. How do I indicate this for teneo? This question is related
>>>> to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>> answers to these questions.
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620808 is a reply to message #134950] Sat, 11 April 2009 01:07 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

You should check out the RCP-Application I wrote for EclipseCon and the
slides I provide there.

The slides are:
https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/EC2009/446

The source code for the complete application:
http://github.com/tomsontom/emf-databinding-example/tree/mas ter

Tom

aappddeevv schrieb:
> Tom Schindl wrote:
>> Hi,
>>
>> Before you decide to use Teneo for your *RCP* application I think that
>> you might reconsider it. Teneo inherits the hibernate "problem" that it
>> is created for short time transactions and is not really useable for
>> long term concurrency (at least this is my way of thinking).
>>
>
> Yes. I looked into this issue over a long period of time and blogged a
> bunch of thoughts. For RCP when using spring (which I like) I found that
> I needed to use the orchestra long session scope (its a pacakge off of
> the myfaces package) that intercepts all methods and swaps in the proper
> session before the method call. This makes the rest of spring behave
> consistently. Of course, you can just hold onto the session object and
> not use spring transactions. There no easy conversation/session
> management like in jboss's seam for RCP.
>
> I have not found any good material on session management for RCP
> applications except that for some "editors" a long session is a must and
> for high latency connections, a long session is needed as well. To be
> honest, I have found that it takes alot of skill to balance session
> lifetime, lazy loading and units of work.
>
> I have looked at CDO but could not determine enough about it to
> understand session management. I liked the concept though and thought
> the wiki documentation was a good start. All together, EMF, teneo and
> CDO is quite an impressive stack.
>
> Tom, since I believe you have good insights I will look into CDO again
> especially around conversations.
>
>
>
>
>> So if you have multiple people are using your application at the same
>> time you'll maybe run into trouble. IMHO the combination of Teneo and
>> CDO is unbeatable for such a scenario though don't know the current
>> state of the CDO-Teneo backend.
>>
>> Tom
>>
>> Martin Taal schrieb:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate xml
>>> file. This is described here: http://www.elver.org (is this what you
>>> mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if that
>>> is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>> I think Ed can answer question b better than I do, I would say model the
>>> same operation in ecore and generate from there, but maybe there are
>>> better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I put
>>> on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database. The
>>>> relationships between tables is not 100% well-defined. In some places
>>>> the relationships exist, in others they must be enforced through the
>>>> application. Over time, some fields may be added to the tables and
>>>> some tables may be added but that is under a separate change
>>>> management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to suit
>>>> their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and generate
>>>> schema updates in forward modeling but that change cycle is not always
>>>> allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and columns
>>>> directly in the ecore model? Object names and table names do not match
>>>> nor do we want them to (the legacy names are very unfriendly)? We also
>>>> need to add sql queries and other tricks to get relationships to work
>>>> in the objects. We only have an ecore model. Typically we model
>>>> through the ecore diagram tool. There is no XSD or annotated java
>>>> classes to derive from. I have used teneo to generate an hbm file but
>>>> I don't think that this is the right place to put the hibernate
>>>> options and it does not appear to be a good idea to place the
>>>> annotations on the generated classes either. What's the best practice
>>>> for this? Are their teneo properties that replace hibernate properties
>>>> that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want to
>>>> automatically bring that operation back into our ecore, how do we do
>>>> that (merge java domain objects bakc into ecore)? This is not strictly
>>>> a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a single
>>>> table in the legacy database but to 3-4 tables that must be joined.
>>>> How do I indicate this for teneo? This question is related to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious answers
>>>> to these questions.
>>>
>
Re: [Teneo] legacy database and hibernate mappings [message #620810 is a reply to message #134937] Sun, 12 April 2009 19:24 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Thanks. Just to let you know of progress, I am generating models and
persisting them in hibernate. I believe the EMF approach allows me to
satisfy the change management requirements I have for the core data model.

One thing I have found is that adding annotations to have the generated
ecore model match my legacy database is proving extremely tricky as I
need to search across persistence options as well as ensure I have added
the appropriate JPA annotations in all the right places. One thing that
I did not count on is that teneo is working hard to persist many aspects
of the EMF model...many more features than my legacy database has. These
comments are based on comparing the teneo HBM to the HibernateTools
generated HBM files and thinking through the objects mapping.

So it appears that I need multiple hibernate/jpa annotations to force
the override that I think is appropriate for my legacy database. At some
point, I am not sure when, it will be easier to create a direct mapping
file and turn off in-memory HBM generation.

One question I have for you is whether teneo allows a combination of HBM
generation and HBM integration much in the same way that hibernate
allows annotations and HBM files to complement and add to each other.

I am not sure how all the teneo users think about this and whether they
have the same legacy database change management constraints that I have.
I'll throw out a thought that a small guide on the teneo website
describing the legacy database usecase and accompanying advice may be
helpful to some like myself.


I think I have worked through my ecorediag issues where etypes and
opposite relationships seemed to get corrupted from time to time.



Martin Taal wrote:
> Hi apdev,
> See comments inline marked with MT>>
>
> gr. Martin
>
> aappddeevv wrote:
>> Martin Taal wrote:
>>> Hi apdev,
>>> With Teneo you can accomplish most of the mapping issues with
>>> annotations in the model.Either in the ecore itself or in a separate
>>> xml file. This is described here: http://www.elver.org (is this what
>>> you mean with Teneo wiki?).
>>> For example table and column naming is set using Table and Column
>>> annotations. You can also implement your own sql naming strategy if
>>> that is easier:
>>> http://www.elver.org/hibernate/extensions.html
>>>
>>
>> Based on your comments, since I am starting with an ecore model
>> (instead of an XSD or annotated java class), it appears that I need to
>> add teneo annotations to the ecore model (which I can do through the
>> diagram interface).
>>
>> If I use this approach, is there a teneo.hibernate corresponding to
>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>> hibernate.
> MT>> The annotations in the model are all JPA (so you should use
> teneo.jpa) with support for some hibernate specific annotations. At
> runtime you can choose to initialize the datastore for standard
> hibernate (the default: HbSessionDataStore) or want to use Hibernate
> Entity Manager (HbEntityDataStore). In your case you should use the
> HbSessionDataStore. So only when defining the annotations in the model
> you should know JPA (the annotations), at runtime you can use classic
> Hibernate. Teneo translates the model JPA annotations to a hbm (in-memory).
>
>>
>> Can I also assume that once I generate the java classes, I can
>> initialize my HbDataStore using the factory and the hibernate
>> annotations will be passed along properly to the underlying hibernate
>> engine? It looks like from experiments that the generated java classes
>> do not have the annotations itself.
> MT>> Correct, based on the annotations and the model itself, Teneo
> generates a hbm in-memory and passes this on to hibernate at startup.
> You can find the hbm when calling the method getMappingXML on the
> datastore.
>
>>
>> Is this right?
>>
>>
>>> I think Ed can answer question b better than I do, I would say model
>>> the same operation in ecore and generate from there, but maybe there
>>> are better options.
>>>
>>> For question c you can use SecundaryTable annotations.
>>>
>>> The supported annotations are listed here:
>>> http://www.elver.org/hibernate/ejb3_features.html
>>>
>>> Let me know if you miss a hibernate-specific annotation, they are
>>> normally easy to add.
>>>
>>> Here are examples of annotated models (in ecore and xml):
>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>
>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>> put on the cc).
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>
>>>> I would like to use Teneo for hibernate access to legacy database.
>>>> The relationships between tables is not 100% well-defined. In some
>>>> places the relationships exist, in others they must be enforced
>>>> through the application. Over time, some fields may be added to the
>>>> tables and some tables may be added but that is under a separate
>>>> change management cycle not solely controlled by our group.
>>>>
>>>> I would like to use Teneo so that we can adapt to database changes
>>>> that we and other groups ask for as well as allow other groups to
>>>> extend our ecore models and more easily update our application to
>>>> suit their needs. Essentially they might extend the database and
>>>> respectively extend the model. I realize that I can model and
>>>> generate schema updates in forward modeling but that change cycle is
>>>> not always allowed for the application groups.
>>>>
>>>>
>>>> Questions on some best practices to help with this:
>>>>
>>>> a) How do I indicate hibernate options for the table name and
>>>> columns directly in the ecore model? Object names and table names do
>>>> not match nor do we want them to (the legacy names are very
>>>> unfriendly)? We also need to add sql queries and other tricks to get
>>>> relationships to work in the objects. We only have an ecore model.
>>>> Typically we model through the ecore diagram tool. There is no XSD
>>>> or annotated java classes to derive from. I have used teneo to
>>>> generate an hbm file but I don't think that this is the right place
>>>> to put the hibernate options and it does not appear to be a good
>>>> idea to place the annotations on the generated classes either.
>>>> What's the best practice for this? Are their teneo properties that
>>>> replace hibernate properties that I should use instead?
>>>>
>>>> b) If someone writes a new method in our domain object and we want
>>>> to automatically bring that operation back into our ecore, how do we
>>>> do that (merge java domain objects bakc into ecore)? This is not
>>>> strictly a teneo question.
>>>>
>>>> c) Some objects that we want in our application do not map to a
>>>> single table in the legacy database but to 3-4 tables that must be
>>>> joined. How do I indicate this for teneo? This question is related
>>>> to (1).
>>>>
>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>> answers to these questions.
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620812 is a reply to message #134989] Mon, 13 April 2009 06:27 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Apdev,
Here are some options (with their values) which can turn of some of the EMF features:
PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
PersistenceOptions.ALWAYS_VERSION --> false
PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false

There is one tricky EMF feature called featuremap which is hard to map manually to an existing database structure. It is
for sure possible that you don't have featuremaps in your model..., but if you have then I think you have to change your
model.

Let me know if you encounter any special legacy mapping (with annotations) which is a lot of manual work but could be
handled by an option.

gr. Martin

aappddeevv wrote:
> Thanks. Just to let you know of progress, I am generating models and
> persisting them in hibernate. I believe the EMF approach allows me to
> satisfy the change management requirements I have for the core data model.
>
> One thing I have found is that adding annotations to have the generated
> ecore model match my legacy database is proving extremely tricky as I
> need to search across persistence options as well as ensure I have added
> the appropriate JPA annotations in all the right places. One thing that
> I did not count on is that teneo is working hard to persist many aspects
> of the EMF model...many more features than my legacy database has. These
> comments are based on comparing the teneo HBM to the HibernateTools
> generated HBM files and thinking through the objects mapping.
>
> So it appears that I need multiple hibernate/jpa annotations to force
> the override that I think is appropriate for my legacy database. At some
> point, I am not sure when, it will be easier to create a direct mapping
> file and turn off in-memory HBM generation.
>
> One question I have for you is whether teneo allows a combination of HBM
> generation and HBM integration much in the same way that hibernate
> allows annotations and HBM files to complement and add to each other.
>
> I am not sure how all the teneo users think about this and whether they
> have the same legacy database change management constraints that I have.
> I'll throw out a thought that a small guide on the teneo website
> describing the legacy database usecase and accompanying advice may be
> helpful to some like myself.
>
>
> I think I have worked through my ecorediag issues where etypes and
> opposite relationships seemed to get corrupted from time to time.
>
>
>
> Martin Taal wrote:
>> Hi apdev,
>> See comments inline marked with MT>>
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> Martin Taal wrote:
>>>> Hi apdev,
>>>> With Teneo you can accomplish most of the mapping issues with
>>>> annotations in the model.Either in the ecore itself or in a separate
>>>> xml file. This is described here: http://www.elver.org (is this what
>>>> you mean with Teneo wiki?).
>>>> For example table and column naming is set using Table and Column
>>>> annotations. You can also implement your own sql naming strategy if
>>>> that is easier:
>>>> http://www.elver.org/hibernate/extensions.html
>>>>
>>>
>>> Based on your comments, since I am starting with an ecore model
>>> (instead of an XSD or annotated java class), it appears that I need
>>> to add teneo annotations to the ecore model (which I can do through the
>>> diagram interface).
>>>
>>> If I use this approach, is there a teneo.hibernate corresponding to
>>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>>> hibernate.
>> MT>> The annotations in the model are all JPA (so you should use
>> teneo.jpa) with support for some hibernate specific annotations. At
>> runtime you can choose to initialize the datastore for standard
>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>> Entity Manager (HbEntityDataStore). In your case you should use the
>> HbSessionDataStore. So only when defining the annotations in the model
>> you should know JPA (the annotations), at runtime you can use classic
>> Hibernate. Teneo translates the model JPA annotations to a hbm
>> (in-memory).
>>
>>>
>>> Can I also assume that once I generate the java classes, I can
>>> initialize my HbDataStore using the factory and the hibernate
>>> annotations will be passed along properly to the underlying hibernate
>>> engine? It looks like from experiments that the generated java
>>> classes do not have the annotations itself.
>> MT>> Correct, based on the annotations and the model itself, Teneo
>> generates a hbm in-memory and passes this on to hibernate at startup.
>> You can find the hbm when calling the method getMappingXML on the
>> datastore.
>>
>>>
>>> Is this right?
>>>
>>>
>>>> I think Ed can answer question b better than I do, I would say model
>>>> the same operation in ecore and generate from there, but maybe there
>>>> are better options.
>>>>
>>>> For question c you can use SecundaryTable annotations.
>>>>
>>>> The supported annotations are listed here:
>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>
>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>> normally easy to add.
>>>>
>>>> Here are examples of annotated models (in ecore and xml):
>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>
>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>> put on the cc).
>>>>
>>>> gr. Martin
>>>>
>>>> aappddeevv wrote:
>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>
>>>>> I would like to use Teneo for hibernate access to legacy database.
>>>>> The relationships between tables is not 100% well-defined. In some
>>>>> places the relationships exist, in others they must be enforced
>>>>> through the application. Over time, some fields may be added to the
>>>>> tables and some tables may be added but that is under a separate
>>>>> change management cycle not solely controlled by our group.
>>>>>
>>>>> I would like to use Teneo so that we can adapt to database changes
>>>>> that we and other groups ask for as well as allow other groups to
>>>>> extend our ecore models and more easily update our application to
>>>>> suit their needs. Essentially they might extend the database and
>>>>> respectively extend the model. I realize that I can model and
>>>>> generate schema updates in forward modeling but that change cycle
>>>>> is not always allowed for the application groups.
>>>>>
>>>>>
>>>>> Questions on some best practices to help with this:
>>>>>
>>>>> a) How do I indicate hibernate options for the table name and
>>>>> columns directly in the ecore model? Object names and table names
>>>>> do not match nor do we want them to (the legacy names are very
>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>> get relationships to work in the objects. We only have an ecore
>>>>> model. Typically we model through the ecore diagram tool. There is
>>>>> no XSD or annotated java classes to derive from. I have used teneo
>>>>> to generate an hbm file but I don't think that this is the right
>>>>> place to put the hibernate options and it does not appear to be a
>>>>> good idea to place the annotations on the generated classes either.
>>>>> What's the best practice for this? Are their teneo properties that
>>>>> replace hibernate properties that I should use instead?
>>>>>
>>>>> b) If someone writes a new method in our domain object and we want
>>>>> to automatically bring that operation back into our ecore, how do
>>>>> we do that (merge java domain objects bakc into ecore)? This is not
>>>>> strictly a teneo question.
>>>>>
>>>>> c) Some objects that we want in our application do not map to a
>>>>> single table in the legacy database but to 3-4 tables that must be
>>>>> joined. How do I indicate this for teneo? This question is related
>>>>> to (1).
>>>>>
>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>> answers to these questions.
>>>>
>>>>
>>
>>


--

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] legacy database and hibernate mappings [message #620813 is a reply to message #135000] Mon, 13 April 2009 15:47 Go to previous message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
I think this is a legacy issue that could be handled by an option. I
have seen the XSD date persistence options but this seems to be another
issue:

a) When creating a datetime field the only EMF options is EDate.
b) The inmemory HBM creates timestamp fields (which is actually what I
want but seems strictly inconsistent with EDate).
c) If you specify one of the EDate fields to be @Version (timestamp
versioning, which is not perfect but that's what the legacy database
has) then the @Version seems to force the field type to
org.eclipse.emf.teneo.hibernate.mapping.XSDDateTime where I really want
type="timestamp". The reasoning would be that @Version marks a java
field which should infer the type (such as timestamp) from the type of
the field.

Perhaps an option that says for version fields that are dates, the type
should be X.


Also,

a) I can't seem to get rid of a generated foreign-key (a FK index
specification) hibernate option on a ManyToOne.
b) Can't seem to force a @Id property to create not-null="true" and
unique=true in the generated HBM automatically. You have to specify it
fully using @Column which does work.


I am sure this can all be handled with the extensions.



Martin Taal wrote:
> Hi Apdev,
> Here are some options (with their values) which can turn of some of the
> EMF features:
> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
> PersistenceOptions.ALWAYS_VERSION --> false
> PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
> PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false
>
> There is one tricky EMF feature called featuremap which is hard to map
> manually to an existing database structure. It is for sure possible that
> you don't have featuremaps in your model..., but if you have then I
> think you have to change your model.
>
> Let me know if you encounter any special legacy mapping (with
> annotations) which is a lot of manual work but could be handled by an
> option.
>
> gr. Martin
>
> aappddeevv wrote:
>> Thanks. Just to let you know of progress, I am generating models and
>> persisting them in hibernate. I believe the EMF approach allows me to
>> satisfy the change management requirements I have for the core data
>> model.
>>
>> One thing I have found is that adding annotations to have the
>> generated ecore model match my legacy database is proving extremely
>> tricky as I need to search across persistence options as well as
>> ensure I have added the appropriate JPA annotations in all the right
>> places. One thing that I did not count on is that teneo is working
>> hard to persist many aspects of the EMF model...many more features
>> than my legacy database has. These comments are based on comparing the
>> teneo HBM to the HibernateTools generated HBM files and thinking
>> through the objects mapping.
>>
>> So it appears that I need multiple hibernate/jpa annotations to force
>> the override that I think is appropriate for my legacy database. At
>> some point, I am not sure when, it will be easier to create a direct
>> mapping file and turn off in-memory HBM generation.
>>
>> One question I have for you is whether teneo allows a combination of
>> HBM generation and HBM integration much in the same way that hibernate
>> allows annotations and HBM files to complement and add to each other.
>>
>> I am not sure how all the teneo users think about this and whether
>> they have the same legacy database change management constraints that
>> I have. I'll throw out a thought that a small guide on the teneo
>> website describing the legacy database usecase and accompanying advice
>> may be helpful to some like myself.
>>
>>
>> I think I have worked through my ecorediag issues where etypes and
>> opposite relationships seemed to get corrupted from time to time.
>>
>>
>>
>> Martin Taal wrote:
>>> Hi apdev,
>>> See comments inline marked with MT>>
>>>
>>> gr. Martin
>>>
>>> aappddeevv wrote:
>>>> Martin Taal wrote:
>>>>> Hi apdev,
>>>>> With Teneo you can accomplish most of the mapping issues with
>>>>> annotations in the model.Either in the ecore itself or in a
>>>>> separate xml file. This is described here: http://www.elver.org (is
>>>>> this what you mean with Teneo wiki?).
>>>>> For example table and column naming is set using Table and Column
>>>>> annotations. You can also implement your own sql naming strategy if
>>>>> that is easier:
>>>>> http://www.elver.org/hibernate/extensions.html
>>>>>
>>>>
>>>> Based on your comments, since I am starting with an ecore model
>>>> (instead of an XSD or annotated java class), it appears that I need
>>>> to add teneo annotations to the ecore model (which I can do through the
>>>> diagram interface).
>>>>
>>>> If I use this approach, is there a teneo.hibernate corresponding to
>>>> the teneo.jpa that I should use? I don't use any of the JPA parts of
>>>> hibernate.
>>> MT>> The annotations in the model are all JPA (so you should use
>>> teneo.jpa) with support for some hibernate specific annotations. At
>>> runtime you can choose to initialize the datastore for standard
>>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>>> Entity Manager (HbEntityDataStore). In your case you should use the
>>> HbSessionDataStore. So only when defining the annotations in the
>>> model you should know JPA (the annotations), at runtime you can use
>>> classic Hibernate. Teneo translates the model JPA annotations to a
>>> hbm (in-memory).
>>>
>>>>
>>>> Can I also assume that once I generate the java classes, I can
>>>> initialize my HbDataStore using the factory and the hibernate
>>>> annotations will be passed along properly to the underlying
>>>> hibernate engine? It looks like from experiments that the generated
>>>> java classes do not have the annotations itself.
>>> MT>> Correct, based on the annotations and the model itself, Teneo
>>> generates a hbm in-memory and passes this on to hibernate at startup.
>>> You can find the hbm when calling the method getMappingXML on the
>>> datastore.
>>>
>>>>
>>>> Is this right?
>>>>
>>>>
>>>>> I think Ed can answer question b better than I do, I would say
>>>>> model the same operation in ecore and generate from there, but
>>>>> maybe there are better options.
>>>>>
>>>>> For question c you can use SecundaryTable annotations.
>>>>>
>>>>> The supported annotations are listed here:
>>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>>
>>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>>> normally easy to add.
>>>>>
>>>>> Here are examples of annotated models (in ecore and xml):
>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>
>>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>>> put on the cc).
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> aappddeevv wrote:
>>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>>
>>>>>> I would like to use Teneo for hibernate access to legacy database.
>>>>>> The relationships between tables is not 100% well-defined. In some
>>>>>> places the relationships exist, in others they must be enforced
>>>>>> through the application. Over time, some fields may be added to
>>>>>> the tables and some tables may be added but that is under a
>>>>>> separate change management cycle not solely controlled by our group.
>>>>>>
>>>>>> I would like to use Teneo so that we can adapt to database changes
>>>>>> that we and other groups ask for as well as allow other groups to
>>>>>> extend our ecore models and more easily update our application to
>>>>>> suit their needs. Essentially they might extend the database and
>>>>>> respectively extend the model. I realize that I can model and
>>>>>> generate schema updates in forward modeling but that change cycle
>>>>>> is not always allowed for the application groups.
>>>>>>
>>>>>>
>>>>>> Questions on some best practices to help with this:
>>>>>>
>>>>>> a) How do I indicate hibernate options for the table name and
>>>>>> columns directly in the ecore model? Object names and table names
>>>>>> do not match nor do we want them to (the legacy names are very
>>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>>> get relationships to work in the objects. We only have an ecore
>>>>>> model. Typically we model through the ecore diagram tool. There
>>>>>> is no XSD or annotated java classes to derive from. I have used
>>>>>> teneo to generate an hbm file but I don't think that this is the
>>>>>> right place to put the hibernate options and it does not appear to
>>>>>> be a good idea to place the annotations on the generated classes
>>>>>> either. What's the best practice for this? Are their teneo
>>>>>> properties that replace hibernate properties that I should use
>>>>>> instead?
>>>>>>
>>>>>> b) If someone writes a new method in our domain object and we want
>>>>>> to automatically bring that operation back into our ecore, how do
>>>>>> we do that (merge java domain objects bakc into ecore)? This is
>>>>>> not strictly a teneo question.
>>>>>>
>>>>>> c) Some objects that we want in our application do not map to a
>>>>>> single table in the legacy database but to 3-4 tables that must be
>>>>>> joined. How do I indicate this for teneo? This question is related
>>>>>> to (1).
>>>>>>
>>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>>> answers to these questions.
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] legacy database and hibernate mappings [message #620815 is a reply to message #135012] Mon, 13 April 2009 19:31 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I answered this post on the EMF newsgroup.

gr. Martin

aappddeevv wrote:
> I think this is a legacy issue that could be handled by an option. I
> have seen the XSD date persistence options but this seems to be another
> issue:
>
> a) When creating a datetime field the only EMF options is EDate.
> b) The inmemory HBM creates timestamp fields (which is actually what I
> want but seems strictly inconsistent with EDate).
> c) If you specify one of the EDate fields to be @Version (timestamp
> versioning, which is not perfect but that's what the legacy database
> has) then the @Version seems to force the field type to
> org.eclipse.emf.teneo.hibernate.mapping.XSDDateTime where I really want
> type="timestamp". The reasoning would be that @Version marks a java
> field which should infer the type (such as timestamp) from the type of
> the field.
>
> Perhaps an option that says for version fields that are dates, the type
> should be X.
>
>
> Also,
>
> a) I can't seem to get rid of a generated foreign-key (a FK index
> specification) hibernate option on a ManyToOne.
> b) Can't seem to force a @Id property to create not-null="true" and
> unique=true in the generated HBM automatically. You have to specify it
> fully using @Column which does work.
>
>
> I am sure this can all be handled with the extensions.
>
>
>
> Martin Taal wrote:
>> Hi Apdev,
>> Here are some options (with their values) which can turn of some of
>> the EMF features:
>> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG --> true
>> PersistenceOptions.ALWAYS_VERSION --> false
>> PersistenceOptions.DISABLE_ECONTAINER_MAPPING --> true
>> PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY --> false
>>
>> There is one tricky EMF feature called featuremap which is hard to map
>> manually to an existing database structure. It is for sure possible
>> that you don't have featuremaps in your model..., but if you have then
>> I think you have to change your model.
>>
>> Let me know if you encounter any special legacy mapping (with
>> annotations) which is a lot of manual work but could be handled by an
>> option.
>>
>> gr. Martin
>>
>> aappddeevv wrote:
>>> Thanks. Just to let you know of progress, I am generating models and
>>> persisting them in hibernate. I believe the EMF approach allows me to
>>> satisfy the change management requirements I have for the core data
>>> model.
>>>
>>> One thing I have found is that adding annotations to have the
>>> generated ecore model match my legacy database is proving extremely
>>> tricky as I need to search across persistence options as well as
>>> ensure I have added the appropriate JPA annotations in all the right
>>> places. One thing that I did not count on is that teneo is working
>>> hard to persist many aspects of the EMF model...many more features
>>> than my legacy database has. These comments are based on comparing
>>> the teneo HBM to the HibernateTools generated HBM files and thinking
>>> through the objects mapping.
>>>
>>> So it appears that I need multiple hibernate/jpa annotations to force
>>> the override that I think is appropriate for my legacy database. At
>>> some point, I am not sure when, it will be easier to create a direct
>>> mapping file and turn off in-memory HBM generation.
>>>
>>> One question I have for you is whether teneo allows a combination of
>>> HBM generation and HBM integration much in the same way that
>>> hibernate allows annotations and HBM files to complement and add to
>>> each other.
>>>
>>> I am not sure how all the teneo users think about this and whether
>>> they have the same legacy database change management constraints that
>>> I have. I'll throw out a thought that a small guide on the teneo
>>> website describing the legacy database usecase and accompanying
>>> advice may be helpful to some like myself.
>>>
>>>
>>> I think I have worked through my ecorediag issues where etypes and
>>> opposite relationships seemed to get corrupted from time to time.
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi apdev,
>>>> See comments inline marked with MT>>
>>>>
>>>> gr. Martin
>>>>
>>>> aappddeevv wrote:
>>>>> Martin Taal wrote:
>>>>>> Hi apdev,
>>>>>> With Teneo you can accomplish most of the mapping issues with
>>>>>> annotations in the model.Either in the ecore itself or in a
>>>>>> separate xml file. This is described here: http://www.elver.org
>>>>>> (is this what you mean with Teneo wiki?).
>>>>>> For example table and column naming is set using Table and Column
>>>>>> annotations. You can also implement your own sql naming strategy
>>>>>> if that is easier:
>>>>>> http://www.elver.org/hibernate/extensions.html
>>>>>>
>>>>>
>>>>> Based on your comments, since I am starting with an ecore model
>>>>> (instead of an XSD or annotated java class), it appears that I need
>>>>> to add teneo annotations to the ecore model (which I can do through
>>>>> the
>>>>> diagram interface).
>>>>>
>>>>> If I use this approach, is there a teneo.hibernate corresponding to
>>>>> the teneo.jpa that I should use? I don't use any of the JPA parts
>>>>> of hibernate.
>>>> MT>> The annotations in the model are all JPA (so you should use
>>>> teneo.jpa) with support for some hibernate specific annotations. At
>>>> runtime you can choose to initialize the datastore for standard
>>>> hibernate (the default: HbSessionDataStore) or want to use Hibernate
>>>> Entity Manager (HbEntityDataStore). In your case you should use the
>>>> HbSessionDataStore. So only when defining the annotations in the
>>>> model you should know JPA (the annotations), at runtime you can use
>>>> classic Hibernate. Teneo translates the model JPA annotations to a
>>>> hbm (in-memory).
>>>>
>>>>>
>>>>> Can I also assume that once I generate the java classes, I can
>>>>> initialize my HbDataStore using the factory and the hibernate
>>>>> annotations will be passed along properly to the underlying
>>>>> hibernate engine? It looks like from experiments that the generated
>>>>> java classes do not have the annotations itself.
>>>> MT>> Correct, based on the annotations and the model itself, Teneo
>>>> generates a hbm in-memory and passes this on to hibernate at
>>>> startup. You can find the hbm when calling the method getMappingXML
>>>> on the datastore.
>>>>
>>>>>
>>>>> Is this right?
>>>>>
>>>>>
>>>>>> I think Ed can answer question b better than I do, I would say
>>>>>> model the same operation in ecore and generate from there, but
>>>>>> maybe there are better options.
>>>>>>
>>>>>> For question c you can use SecundaryTable annotations.
>>>>>>
>>>>>> The supported annotations are listed here:
>>>>>> http://www.elver.org/hibernate/ejb3_features.html
>>>>>>
>>>>>> Let me know if you miss a hibernate-specific annotation, they are
>>>>>> normally easy to add.
>>>>>>
>>>>>> Here are examples of annotated models (in ecore and xml):
>>>>>> http://www.elver.org/hibernate/ejb3_examples.html
>>>>>>
>>>>>> btw, support for Teneo is given on the main EMF newsgroup (which I
>>>>>> put on the cc).
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> aappddeevv wrote:
>>>>>>> EMF+Teneo+Hibernate+Spring+RCP
>>>>>>>
>>>>>>> I would like to use Teneo for hibernate access to legacy
>>>>>>> database. The relationships between tables is not 100%
>>>>>>> well-defined. In some places the relationships exist, in others
>>>>>>> they must be enforced through the application. Over time, some
>>>>>>> fields may be added to the tables and some tables may be added
>>>>>>> but that is under a separate change management cycle not solely
>>>>>>> controlled by our group.
>>>>>>>
>>>>>>> I would like to use Teneo so that we can adapt to database
>>>>>>> changes that we and other groups ask for as well as allow other
>>>>>>> groups to extend our ecore models and more easily update our
>>>>>>> application to suit their needs. Essentially they might extend
>>>>>>> the database and respectively extend the model. I realize that I
>>>>>>> can model and generate schema updates in forward modeling but
>>>>>>> that change cycle is not always allowed for the application groups.
>>>>>>>
>>>>>>>
>>>>>>> Questions on some best practices to help with this:
>>>>>>>
>>>>>>> a) How do I indicate hibernate options for the table name and
>>>>>>> columns directly in the ecore model? Object names and table names
>>>>>>> do not match nor do we want them to (the legacy names are very
>>>>>>> unfriendly)? We also need to add sql queries and other tricks to
>>>>>>> get relationships to work in the objects. We only have an ecore
>>>>>>> model. Typically we model through the ecore diagram tool. There
>>>>>>> is no XSD or annotated java classes to derive from. I have used
>>>>>>> teneo to generate an hbm file but I don't think that this is the
>>>>>>> right place to put the hibernate options and it does not appear
>>>>>>> to be a good idea to place the annotations on the generated
>>>>>>> classes either. What's the best practice for this? Are their
>>>>>>> teneo properties that replace hibernate properties that I should
>>>>>>> use instead?
>>>>>>>
>>>>>>> b) If someone writes a new method in our domain object and we
>>>>>>> want to automatically bring that operation back into our ecore,
>>>>>>> how do we do that (merge java domain objects bakc into ecore)?
>>>>>>> This is not strictly a teneo question.
>>>>>>>
>>>>>>> c) Some objects that we want in our application do not map to a
>>>>>>> single table in the legacy database but to 3-4 tables that must
>>>>>>> be joined. How do I indicate this for teneo? This question is
>>>>>>> related to (1).
>>>>>>>
>>>>>>> I've read through the teneo wiki but am not sure I saw obvious
>>>>>>> answers to these questions.
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

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
Previous Topic:[Teneo] legacy database and hibernate mappings
Next Topic:Compare BPEL files
Goto Forum:
  


Current Time: Wed Apr 24 23:58:28 GMT 2024

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

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

Back to the top