Giter VIP home page Giter VIP logo

hibernateosgi's Introduction

HibernateOSGi

This repository provides example client bundles for using Hibernate ORM in an OSGi environment. There is currently only one example, but more are in the works. All examples assume Apache Karaf is the runtime, however each should be able to be molded for alternative environments.

H2

All examples use in-memory H2.

HibernateOSGi_ContainerManaged

This bundle assumes an Enterprise OSGi environment and an OSGi container-managed EntityManager. src/main/resources/OSGI-INF/blueprint/blueprint.xml sets up the persistence unit and maps the OSGi container-controlled EntityManager to a Bean property.

/datasource-h2.xml provides a blueprint to be installing in Karaf. This examples' feature.xml file automatically does so. Note that the "blueprint:file:...datasource-h2.xml" will need to be modified. This datasource route is taken to allow the persistence.xml to use a JTA Data Source via Karaf's JNDI.

features.xml shows an example list of (somewhat) order-dependent bundles that need to be activated in the runtime. This can be used directly in Karaf. Note that JTA, JPA, and JNDI dependency bundles can be replaced by Karaf's "transaction", "jpa", and "jndi" features. However, I list the bundles explicitly as a reference.

blueprint.xml also provides three Karaf Shell commands for use during testing: "dp:add {name}", "dp:getall", and "dp:deleteall"

To run the example:

  1. $KARAF_HOME/bin/karaf
  2. features:addurl file:/.../HibernateOSGi/HibernateOSGi_ContainerManaged/features.xml
  3. features:install hibernate-test
  4. dp:add foo
  5. dp:getall (should print "{id}, foo")
  6. dp:deleteall
  7. dp:getall (nothing should print)

HibernateOSGi_AppManaged

This bundle demonstrates how to use Hibernate SessionFactories or JPA EntityManagerFactories directly in your application, rather than relying on the OSGi container-managed EntityManager.

features.xml shows an example list of (somewhat) order-dependent bundles that need to be activated in the runtime.

blueprint.xml also provides six Karaf Shell commands for use during testing: "dp:add {name}", "dp:getall", "dp:deleteall", "dp:addjpa {name}", "dp:getalljpa", and "dp:deletealljpa". The commands proceeded by "jpa" utilize JPA's EntityManagerFactory, while the others directly use Hibernate's SessionFactory.

To run the example:

  1. $KARAF_HOME/bin/karaf
  2. features:addurl file:/.../HibernateOSGi/HibernateOSGi_AppManaged/features.xml
  3. features:install hibernate-test
  4. dp:add foo
  5. dp:getall (should print "{id}, foo")
  6. dp:deleteall
  7. dp:getall (nothing should print)
  8. dp:addjpa foo
  9. dp:getalljpa (should print "{id}, foo")
  10. dp:deletealljpa
  11. dp:getalljpa (nothing should print)

hibernateosgi's People

Contributors

brmeyer avatar davidkeen avatar

Watchers

 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.