Pages

Monday, December 27, 2010

Querying EMF Models using Model Query

Querying i.e. retrieving the list of EMF objects that meet a specific criteria by only navigating the object graph, finding the right objects, plus loops and if-elses... is inconvenient! Not to mention the performance of the lookup would be very slow on large models.

Fortunately there are several solutions (actually, alternatives, since there are still some restrictions) for this:

HQL on CDO/Teneo + Hibernate

This one is sort of cheating, because it doesn't really use EMF capabilities at all, but under the hood delegates to the underlying persistence storage which is Hibernate which in turn is backed by a relational database (such as MySQL, HSQLDB, PostgreSQL, you name it).

The objects returned by Hibernate are then "converted" into EMF Objects. Actually they're already EMF Objects (of course!) but I suspect CDO/Teneo does additional processing like attaching the objects to the proper EMF Resource.

The code is much more compact and developer-friendly: (especially if you're a Hibernate developer)

Conclusion

I think using HSQL is the best solution from both the performance standpoint and ease of use.

However it requires to use a data store that supports a query language, such as the Hibernate Data Store (I think the CDO Objectivity data store should also support querying).

In theory, CDO supports pluggable query handler so that CDO Data Stores are free to implement their own optimized query language (with parameter support!) However whether this applies in practice (for other data stores), I still have to find out. :-)

11 comments:

CDO supports a number of different storage backends like plain SQL databases, Hibernate, Objectivity/DB, DB4O and MongoDB (coming soon). Most of these come with their own, native query language and CDO is able to execute queries in these languages on the server by delegating directly to the storage backend.

In addition we've just added the first "common" query language handler for OCL queries that works independently of the configured storage backend. With the same bugzilla 256931 we've introduced the ability to have local dirty state be considered by the query execution engine on the server.

The OCL query handler seems cool if it's practical to work with, i.e. querying a medium sized database. How it compares to HQL? With anything bigger than tiny models query performance is important, not just convenience..

@Etienne thanks for the info on EMFPath. It looks very convenient, I still doubt its performance though, as I believe it still requires the EMF models be loaded into memory.

When models can occupy several hundred MBs, I believe the only performant querying is one that is index-based (not just iterative, no matter how many threads you use, since the loading of models from disk is one bottleneck).

While versions can takeBuy Cheap RS Gold up hundreds of MBs, In my opinion the one performant querying is certainly one that's index-based (not just repetitive, no matter how a lot of posts you utilize, Sell Rs Goldsince the launching associated with versions through computer is a bottleneck).

Ubisoft has confirmed that his remarkable musical title Rocksmith, mainly for players who want to learn rs gold 07 to play guitar or bass, has sold 1.4 million copies worldwide since its launch on the market a year ago and medio.Adem s, the company gala has been referred to a report which highlights that enjoy Rocksmith is "the fastest way to learn to play the guitar." So much cheap 07 runescape gold so, that about 95 percent of users say they have improved their ability to guitarra.Por addition, Ubisoft has released more curious as other data that have been downloaded more than 3 million additional songs, or have performed more than 120,000 million runescape gold shop musicales.

Visio 2010 Download helps you make diagrams look attractive with a wide range of formatting tools and design options, including modern shapes and visuals, a rich gallery of themes, and Live Preview.Project 2010 Download includes a timeline view that is automatically displayed above other views, showing a concise overview of the entire schedule. You can add tasks to the timeline and even print it for an attractive summary report of the entire project. Or you can paste it into an e-mail for an instant report with no fuss.Project Standard 2010 includes all the features and functionality of Acrobat 9 Pro, plus the ability to unify the widest range of content in a PDF Portfolio, create interactive presentations with Adobe Presenter software, easily convert and share video in PDF, create PDF maps, convert virtually any 2D and 3D designs to PDF, and enjoy expanded 3D capabilities with the new Adobe 3D Reviewer.

About Me

Hendy Irawan is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.