forked from molgenis/molgenis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added molgenis-data-jpa documentation
- Loading branch information
erwinwinder
committed
Jan 15, 2014
1 parent
d7b6547
commit c654006
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
## Introduction | ||
The molgenis-data-jpa package is an jpa data backend for Molgenis. All entities descibed in the Molgenis dsl model xml files and that are generated using the Molgenis generator can be used with the Data Api. It provides functionality to query, create, update and delete jpa entities. | ||
|
||
For this package to work you must configure your spring applicationcontext for use with jpa. You can do this by including the `org.molgenis.DatabaseConfig` spring configuration class. | ||
|
||
## Core molgenis-data-jpa classes | ||
<img src="molgenis-data-jpa.png" /> | ||
|
||
**The light grey classes are provided by the core molgenis-data module** | ||
|
||
**The classes marked 'generated' will be generated by the Molgenis generator** | ||
|
||
### JpaEntity | ||
The JpaEntity interface is implemented by all jpa entities. The concrete jpa entities are generated by the Molgenis generater according to the domain specific xml configuration files. The entities are strongly typed but they also implement the `Entity` interface so you can them like any other entity implementation. | ||
|
||
The entities contain a field named `ENTITY_NAME` that contains the name of the entity. | ||
Alsp for all fieldnames constants are generated. | ||
|
||
### JpaRepository | ||
For all jpa entities defined in the configuration file a jpa repository is generated that is derived from the `AbstractJpaRepository`. It is a wrapper around the `javax.persistence.EntityManager`. For every jpa entity there is a strongly type jpa repository. | ||
|
||
The required metadata classes are also generated. | ||
|
||
### JpaEntitySourceImpl | ||
This is generated to contain all jpa repositories. One exists per application. The url is always `jpa://`. | ||
|
||
### JpaEntitySourceFactory | ||
Just returns the generated `JpaEntitySourceImpl` as there can be only one JpaEntitySource per application. | ||
The url prefix is `jpa://`. | ||
|
||
### JpaEntitySourceRegistrator | ||
This class will registers the jpa entity source if it is in your spring context. It is annotated with `@Component` so when you have this class inculded in your spring component scan, everything will be automatically registered (example `@ComponentScan("org.molgenis")`). | ||
|
||
## Usage example | ||
|
||
*** Model *** | ||
|
||
``` | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<molgenis name="org.molgenis"> | ||
<module name="test"> | ||
<entity name="Person"> | ||
<field name="id" type="autoid" /> | ||
<field name="name" type="string" /> | ||
</entity> | ||
</module> | ||
</molgenis> | ||
``` | ||
|
||
*** Find a Person with name 'Piet' *** | ||
|
||
``` | ||
DataService dataService = ...; | ||
Query q = new QueryImpl().eq(Person.NAME, "Piet"); | ||
Person person = dataService.findOne(Person.ENTITY_NAME, q); | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.