|
|
Re: Model Persistence with Teneo [message #525240 is a reply to message #525020] |
Mon, 05 April 2010 19:18 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Vishal,
Here is a longer answer, let me know if this answers your question or not ofcourse...
Yes it is theoretically possible to store models in a database (Teneo maps the model correctly), but I advice to store
models as blobs in the database or on the file system and use annotations to tell Teneo to store references to the model
in a special way:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Asso ciation_Mapping#Storing_references_to_Ecore_Model_Elements
The reason not to persist an ecore model in the database is that you would also need to persist the ecore (and
XMLTypePackage) themselves in the database (as there are references from your model to the ecore/xmltype model
themselves). This results in different obstacles as there can only be one instance of the ecore model itself in memory
(the one represented by the EcorePackage class) and reading another ecore model from the database does not work. In
addition some references to ecore model elements are through eannotations, which are not persisted as foreign key
references in the databases (but as strings), this results in incorrect references when loading a model from the database.
Storing an epackage as a blob prevents these issues as the resolving of references to other epackages is done when
reading/parsing the blob in ecore resource. The resolving is done against the epackage registry set in the resourceset.
Another thing to take into account: persisting models (in the database) can only work for dynamic EMF and not for models
which have generated model code. At least when using the global package registry. In the global package registry for a
generated model the EPackage is always represented by the generated EPackage class instance (of which there is only one
in-memory at all times) and not by an EPackage read from a persistent store. Also if your model has generated model code
you can use Teneo's model reference approach to store references to the model themselves while the model is represented
by the singleton generated epackage class.
Note, you can tell Teneo which package registry to use through the PackageRegistryProvider class, it is also possible to
set the EPackage registry in a ThreadLocal in that class.
I have developed some custom solutions for customers which store models themselves in the database and also
automatically create new tables/database schemas are registered in the model store. This work is however not open source.
gr. Martin
Vishal wrote:
> hi,
>
> Is it possible to persist the emf model (and not model instance) using
> teneo? Basically want to store the model data in RDBMS as rows. The db
> structure would be based upon the metamodel.
>
> Have gone through forums & found certain topics where it definitely
> seems possible but not getting the clearer picture out of them.
>
> Regards
> Vishal
--
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.04305 seconds