|
Re: Teneo/Hibernate autogenerated fields indices [message #481511 is a reply to message #481434] |
Fri, 21 August 2009 10:30 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Mikhail,
Hmm, yes this should be possible but not currently done by Teneo. It makes for sure sense to have an index on the
discriminator column as hibernate must use this column it when doing querying for a specific type. For the version
column I am not sure if it makes a lot of difference, the version column is used in update statements which always also
have the primary key in the select. Let me know if you have other/more info on this.
Can you enter a bugzilla feature request for this (to add index on discriminator)?
btw, are you persisting ecore models? I recently came to the conclusion that persisting an ecore model should not be
done in the standard hibernate way (using specific tables for emodelelement/eobject etc.). The persistence works fine
but when reading ecore models from the database they need to be aligned with already loaded models in memory (one of
them the ecore/xmltype models) and this is not done by hibernate/teneo (not in the scope for hibernate/teneo to do
that). I can explain in more detail if you want, let me know.
gr. Martin
Mikhail Kadan wrote:
> Hello.
>
> I'm using SINGLE_TABLE inheritance mapping strategy for my EMF ECore
> model, so I have DTYPE field automatically generated in my table. Is it
> possible to add index to this field using Teneo API or EMF model
> annotations? And is itpossible to add index to E_VERSION field?
>
> Thanks.
>
--
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/Hibernate autogenerated fields indices [message #483055 is a reply to message #482900] |
Sun, 30 August 2009 14:18 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi,
An enchantment request is always great :-)
To answer your question:
Let's use an example. Say that you have a specific Domain model called Domain which contains own EDataTypes and refers
to EDataTypes in Ecore (the XMLTypePackage). When persisting the Domain model package in a Teneo/Hibernate store also
the references to the EDataTypes in the XMLTypePackage need to be stored, so also the XMLTypePackage needs to be stored.
The same applies to any references to the EcorePackage itself. So also the EPackage itself needs to be stored in the
database.
This works, so you can persist/save all these EPackages correctly in the database. The issue occurs when reading the
EPackage back from the database. What hibernate will do is read the Domain package and, as it references the
XMLTypePackage and possibly also the EcorePackage, it will also read those from the database.
So after reading the Domain package from the database there is a new instance of the EcorePackage/XMLTypePackage in
memory also.
But this is an invalid situation! The Domain package instance should not refer to these new EcorePackage/XMLTypePackage
instances but to the one single in-memory instance of the EcorePackage/XMLTypePackage.
Okay, having said this, is there no other way to persist models? Yes there is but then as a xml/xmi blob. If you persist
Ecore Packages as xmi through the EcoreResource then when reading them the references to other EPackages (as Ecore) are
resolved using a PackageRegistry. So in xmi it is possible to handle references which are resolved locally (in the same
xmi) or through a packageregistry.
Then why not implement the same resolving behavior for Hibernate? The answer is that this is difficult (nothing is
impossible ofcourse given enough time and funds) because a model element can reference a type from XMLTypePackage or the
EcorePackage but can also reference types defined in its own package. The reference to 'internal' types should be
persisted as 'hard' foreign keys while the references to ecore types should be done using 'soft-like' references. So
when persisting certain references to certain instances should be persisted differently then references to other
instances. Afaik this is not possible with hibernate.
So what if my model references ecore model elements? If store the ecore model as blobs then I can't refer to the model
elements? Yes, you can see here:
http://www.elver.org/hibernate/hibernate_relations.html#exte rnal
Let me know if there are still questions about this.
gr. Martin
Mikhail Kadan wrote:
> Hello.
>
> I've entered enchantment request:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=287970
>
> ---------------------------
>
> It would also be very useful to know what you have discovered about
> persisting ecore models. Do you mean that mixing Teneo and standard emf
> mechanisms of loading models may lead to some unexpected errors with EMF
> caches? Can you explain this a bit further?
>
> Thanks.
>
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.03150 seconds