Giter Club home page Giter Club logo

eclipselink-and-hibernate-jpa-osgi's Introduction

Hibernate and EclipseLink in an OSGi Runtime and Eclipse 4

This repo shows how to use JPA in an OSGi environment and with Eclipse 4.

It provides products for both EclipseLink and Hibernate.

Building and running the projects

cd com.vogella.jpa
./mvnw clean verify

After the successful build you can navigate to either the /home/simon/git/com.vogella.jpa/com.vogella.jpa.product.eclipselink/target/products/vogella-jpa-eclipselink/your OS/your ws/your arch/vogella-jpa-eclipselink or /com.vogella.jpa/com.vogella.jpa.product.hibernate/target/products/vogella-jpa-hibernate/your OS/your ws/your arch/vogella-jpa-hibernate and run the vogella-jpa-eclipselink or vogella-jpa-hibernate runnable.

Architecture

The com.vogella.jpa.e4.client bundle, which contains the Eclipse 4 application and implicitly uses EclipseLink or Hibernate is completely decoupled from the underlying ORM mapper.

jpa osgi architecture

I do not want to compare these two JPA implementations, but just mention that it is easier to include EclipseLink into a project, which uses an OSGi runtime, e.g., Eclipse, because for Hibernate it was still necessary to add the Eclipse-BuddyPolicy: registered instruction in the models MANIFEST.MF file and to register the com.vogella.jpa.service.eclipselink project as buddy (Eclipse-RegisterBuddy: com.vogella.jpa.model).

Another point is that EclipseLink provides their OSGi bundles in a p2 update site (http://download.eclipse.org/rt/eclipselink/updates/) and Hibernate had to be added to the dependencies project, which generates a p2 update site. See dependencies for further information.

Development

Building the project with Maven Tycho is nice, but as a developer you might want to see the code und run it from the Eclipse IDE. Therefore just clone and import the project, set the target platform, which is specified in the com.vogella.jpa.target project, and run the com.vogella.jpa.eclipselink.product product or the com.vogella.jpa.hibernate.product product.

The Projects

dependencies

The dependencies projects uses bnd-platform in order to generate a p2 update site for the H2 database and the Hibernate hibernate dependencies. See build.gradle and bnd-platforms documentation to see how this is done.

But no worries the p2 update site, which is generated is already available here: https://dl.bintray.com/simon-scholz/H2-Database-Engine/ and also being used in the target platform definition file.

com.vogella.jpa.target

This project consists of a com.vogella.jpa.target.target target definition file, which should be set as target platform for the workspace so that all projects compile.

com.vogella.jpa.model

This is a simple data model for the clients containing a Todo entity and an TodoService interface, but completely decoupled from EclipseLink or Hibernate. So it is pretty much like a DAO or a Spring data repository.

Implement the TodoService interface and registers this implementation as an OSGi service so that it can the obtained by clients.

Depending on which product is started com.vogella.jpa.service.eclipselink or com.vogella.jpa.service.hibernate will be part of the product and therefore provide the actual implementation of the TodoService.

com.vogella.jpa.e4.client

This client is an Eclipse 4 RCP application, which only has a dependency to the com.vogella.jpa.model package and simply injects the TodoService into a sample part in order to show Todo objects in a sample part.

Please feel free to add new features like deleting or adding Todo objects, since the TodoService service already offers these methods as well.

Other projects

The other projects are just containing the features and products for either EclipseLink or Hibernate.

Contributing

Feedback is highly appreciated and pull requests are appreciated even more.

So please feel free to ask for enhancements or offer pull requests for missing features.

eclipselink-and-hibernate-jpa-osgi's People

Contributors

simonscholz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.