Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EMF/Teneo 1.0.4/EclipseLink Support"

< EMF
Line 12: Line 12:
 
Teneo/EclipseLink provides a full implementation of EMF's Resource interface named EclipseLinkResourceImpl. It enables applications to load and save EMF models from or to relational databases and to manage their lifecycle directly through EMF's built-in persistence API, i.e. the ResourceSet interface. EclipseLinkResourceImpl represents an almost complete abstraction from JPA mappings and EclipseLink APIs and makes accessing models in databases, from an EMF point of view, as natural as loading or saving models from files.
 
Teneo/EclipseLink provides a full implementation of EMF's Resource interface named EclipseLinkResourceImpl. It enables applications to load and save EMF models from or to relational databases and to manage their lifecycle directly through EMF's built-in persistence API, i.e. the ResourceSet interface. EclipseLinkResourceImpl represents an almost complete abstraction from JPA mappings and EclipseLink APIs and makes accessing models in databases, from an EMF point of view, as natural as loading or saving models from files.
  
Along with EclipseLinkResourceImpl a dedicated ''eclipselink'' URI protocol and a underlying resource factory named EclipseLinkResourceFactoryImpl have been defined. They make sure that the resources through which models referenced by URIs starting with ''eclipselink:/...'' are instances of EclipseLinkResourceImpl.
+
Along with EclipseLinkResourceImpl a dedicated ''eclipselink'' URI protocol and a underlying resource factory named EclipseLinkResourceFactoryImpl have been defined. They make sure that the resources through which models that are referenced by URIs starting with ''eclipselink:/...'' get loaded are instances of EclipseLinkResourceImpl.
  
// create EclipseLink URI for saving/loading library model in/from database
+
  // create EclipseLink URI for saving/loading library model in/from database
String query = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),
+
  String query = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
+
  uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
+
  
// save library model instance in database
+
  // save library model instance in database
ResourceSet resourceSet1 = new ResourceSetImpl();
+
  ResourceSet resourceSet1 = new ResourceSetImpl();
resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
+
  resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
resource1 = resourceSet1.createResource(uri);
+
  resource1 = resourceSet1.createResource(uri);
  
assertTrue(resource1 instanceof EclipseLinkResourceImpl);
+
  assertTrue(resource1 instanceof EclipseLinkResourceImpl);
assertFalse(resource1.isLoaded());
+
  assertFalse(resource1.isLoaded());
  
resource1.getContents().add(library1);
+
  resource1.getContents().add(library1);
  
assertTrue(resource1.isLoaded());
+
  assertTrue(resource1.isLoaded());
  
resource1.save(Collections.EMPTY_MAP);
+
  resource1.save(Collections.EMPTY_MAP);
  
 
== Building Model-based Rich Client Applications on top of Teneo and EclipseLink ==
 
== Building Model-based Rich Client Applications on top of Teneo and EclipseLink ==

Revision as of 01:31, 16 March 2009

Teneo 1.0.4 provides support for EclipseLink. The following sections explain the principal features it includes and give advice how they can be used for building model-based applications on top of relational databases.

Creating EclipseLink/JPA Mappings for EMF models

Three possibilities:

  • Model-driven
  • Meet-in-the-middle
  • Schema-driven

Accessing EMF Models in Databases using the EclipseLink Resource

Teneo/EclipseLink provides a full implementation of EMF's Resource interface named EclipseLinkResourceImpl. It enables applications to load and save EMF models from or to relational databases and to manage their lifecycle directly through EMF's built-in persistence API, i.e. the ResourceSet interface. EclipseLinkResourceImpl represents an almost complete abstraction from JPA mappings and EclipseLink APIs and makes accessing models in databases, from an EMF point of view, as natural as loading or saving models from files.

Along with EclipseLinkResourceImpl a dedicated eclipselink URI protocol and a underlying resource factory named EclipseLinkResourceFactoryImpl have been defined. They make sure that the resources through which models that are referenced by URIs starting with eclipselink:/... get loaded are instances of EclipseLinkResourceImpl.

 // create EclipseLink URI for saving/loading library model in/from database
 String query = EclipseLinkResourceUtil.createContentsEqualQuery(LibraryPackage.eINSTANCE.getLibrary(),LibraryPackage.eINSTANCE.getLibrary_Name(), library1.getName());
 uri = EclipseLinkResourceUtil.createEclipseLinkURI(TEST_PERSISTENCE_UNIT_NAME, query);
 // save library model instance in database
 ResourceSet resourceSet1 = new ResourceSetImpl();
 resourceSet1.getLoadOptions().putAll(getTestPersistenceUnitProperties());
 resource1 = resourceSet1.createResource(uri);
 assertTrue(resource1 instanceof EclipseLinkResourceImpl);
 assertFalse(resource1.isLoaded());
 resource1.getContents().add(library1);
 assertTrue(resource1.isLoaded());
 resource1.save(Collections.EMPTY_MAP);

Building Model-based Rich Client Applications on top of Teneo and EclipseLink

--Stephaneberle9.gmail.com 05:16, 16 March 2009 (UTC)

Back to the top