Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

This is an easly plugable module for the mangoo I/O Framework to work with Hibernate.

License

Notifications You must be signed in to change notification settings

svenkubiak/mangooio-hibernate-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Travis Build Status

Hibernate extension for the mangoo I/O framework

This is an easly plugable extension for the mangoo I/O framework to work with Hibernate.

Requires Java 17.

Setup

  1. Add the mangooio-hibernate-extension dependency to your pom.xml:
	<dependency>
 		<groupId>de.svenkubiak</groupId>
		<artifactId>mangooio-hibernate-extension</artifactId>	
		<version>x.x.x</version>	
	</dependency>
  1. Configure Hibernate in your mangoo I/O config.props, e.g.
	[hibernate]
        models = de.svenkubiak.mangooio.models
        hbm2ddl.auto = create-drop
        connection.driver_class = org.apache.derby.jdbc.EmbeddedDriver
        connection.url = jdbc:derby:memory/derbydb
        connection.username = username 
        connection.password = password
        dialect = org.hibernate.dialect.DerbyTenSevenDialect
        current_session_context_class = thread
  1. Inject the DataStore where needed
    @Inject
    DataStore dataStore;

Usage

  1. Using wrapper methods
    Person person = new Person();
    
    dataStore.save(person);
    dataStore.update(person); 
    dataStore.saveOrUpdate(person);
  1. Using find methods
    Person p = dataStore.findOne("FROM Person p WHERE p.firstname = 'Foo'");
  1. Using Hibernate Criteria
    Session session = dataStore.getSession();
    
    Criteria critera = session.createCriteria(Person.class);
    criteria.add(Restrictions.eq("firstname", "Foo"));
    Person p = (Person) critera.uniqueResult();

About

This is an easly plugable module for the mangoo I/O Framework to work with Hibernate.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages