Martin Taal's Blog

About EMF, Teneo, CDO, Texo, Hibernate, Open-Source ERP and other topics

EMF Teneo: External References and persisting EObjects as primitive types

leave a comment »

Recently I have spend some time adding some nice new features to Teneo:

  • I made it easier to persist references to EObjects as varchars (URI), i.e. as external references
  • it is now possible to persist EObjects as hibernate user types/simple types

Teneo for a while already had the possibility to store external references as a string in the database. The URI to the object is persisted in this case. This makes it possible to persist part of your model in an XML file and part in the database. When reading objects from the database the references to the objects in XML are automatically handled/resolved.

I now made it a bit easier to work with these External references. You can now annotate an EClass with the @External annotation (as an EAnnotation). This gives you:

  • each EReference to this EClass is assumed to be external, the URI of the referenced object is stored in a VARCHAR column
  • no table is created for the externalized EClass

Ofcourse you can still also annotated individual EReferences with @External, the EClass and EReference annotations can be used next to eachother.

Another nice addition is the ability to store an EObject as a Hibernate user type. Before it was only possible to store values of EAttributes using a Hibernate user type. The latest Teneo build now makes it possible to annotate an EReference or an EClass with the @Type annotation. If the EClass is annotated then all EReferences to this EClass will be persisted as a hibernate user type and the EClass will not have its own table.

The @Type annotation has a type attribute which should contain the full classname of the hibernate user type implementation. For an ecore example with several examples of the user type annotation, check out this ecore model (See the Name EDataType and the Certificate EClass for specific annotations).

I hope this is useful, thanks for reading and if you are interested feel free to give feedback or ask questions on the EMF newsgroup or forum.

gr. Martin!

Advertisements

Written by martintaal

December 12, 2011 at 2:14 pm

Posted in Teneo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: