This chapter will give you some fundamental principles about MDF. If you understand them it should be a lot easier to create an application based on MDF.
There is no need for many words here:
MDF has 3 Abstract entities that you can extend. The minimum requirement is to create 1 subclass of
ChemicalCompound. An application can have multiple types of
ChemicalCompounds. If security is enabled, users can be limited to only see certain types of
ChemicalCompound can be associated with a
Containable. Consider you operate a factory and produce compound A. Now each lot of compound A might have slightly different properties and you must be able to track it. What you sell to the customer is a container containing a specific lot of compound A. Hence a lot is a
Containable can then be put into a
ChemicalCompoundContainer. This entity represents a physically available sample of a
The chemical structure and mixture data are stored in the fixed classes
Due the design of MDF you can create different types of applications from simple compounds databases up to security enabled chemical inventory system.
Spring Data JPA
Spring Data JPA is a technology for creating data access layers. A Spring Data JPA repository offers methods for searching and paging. Developers can then add their custom search methods to a repository by following a defined syntax:
Some examples on a
- findByFirstname(String firstname)
- findByFirstnameStartingWith(String firstname)
- findByLastnameAndFirstname(String name)
- findByAgeLessThan(int age)
To find an entity based on criteria of a referenced entity, that referenced entity must come before the searched property:
- findByAddressCity(String city)
This would return all users from a specific city.
See Spring Data JPA Reference for more information.
QueryDSL is a framework for creating type-safe SQL-like queries. It is integrated with Spring Data JPA. The repositories in MDF have methods
findOne(Predicate predicate) and
findAll(Predicate predicate). A predicate is like an SQL WHERE-clause.
To make this work your project must be configured so that QueryDSL automatically generates "query classes" (metomodel classes) for each of your JPA entities. These classes are named "QEntityName". See maven configuration to enable this for maven.
A simple example:
QTestCompound qCompound = QTestCompound.testCompound; Predicate predicate = qCompound.cas.eq(compound.getCas()); TestCompound result = getRepository().findOne(predicate);
You can create a lot more complex queries with this. In fact the chemical structure search makes use QueryDSL to combine the structure query with a property query into one single predicate. This is achieved by exposing Bingo Cartridge functions to hibernate using a custom dialect that extends
The take-away message is that you can run pretty much any query you like without creating any custom methods. You only need to create the predicate and call the
findOne(Predicate predicate) or
findAll(Predicate predicate) method.
Above information gave you a basic understanding behind the principles of MDF. If you want to start creating your first MDF application, please see the MDF Tutorial.