HIT - A Hibernate quickstart library

Hibernate Induction Trigger - A Hibernate quickstart library

License

License

GroupId

GroupId

com.github.mrstampy
ArtifactId

ArtifactId

hit
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

jar
Description

Description

HIT - A Hibernate quickstart library
Hibernate Induction Trigger - A Hibernate quickstart library
Source Code Management

Source Code Management

https://github.com/mrstampy/hitman.git

Download hit

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mrstampy/hit/ -->
<dependency>
    <groupId>com.github.mrstampy</groupId>
    <artifactId>hit</artifactId>
    <version>1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mrstampy/hit/
implementation 'com.github.mrstampy:hit:1.2'
// https://jarcasting.com/artifacts/com.github.mrstampy/hit/
implementation ("com.github.mrstampy:hit:1.2")
'com.github.mrstampy:hit:jar:1.2'
<dependency org="com.github.mrstampy" name="hit" rev="1.2">
  <artifact name="hit" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mrstampy', module='hit', version='1.2')
)
libraryDependencies += "com.github.mrstampy" % "hit" % "1.2"
[com.github.mrstampy/hit "1.2"]

Dependencies

compile (40)

Group / Artifact Type Version
org.slf4j : slf4j-api Optional jar 1.7.5
org.slf4j : jcl-over-slf4j Optional jar 1.7.5
org.slf4j : log4j-over-slf4j Optional jar 1.7.5
org.slf4j : jul-to-slf4j Optional jar 1.7.5
ch.qos.logback : logback-classic Optional jar 1.0.13
ch.qos.logback : logback-core Optional jar 1.0.13
org.hibernate : hibernate-core Optional jar 4.2.8.Final
org.hibernate : hibernate-entitymanager Optional jar 4.2.8.Final
org.hibernate.common : hibernate-commons-annotations Optional jar 4.0.2.Final
org.hibernate.javax.persistence : hibernate-jpa-2.0-api Optional jar 1.0.1.Final
org.hibernate : hibernate-ehcache Optional jar 4.2.8.Final
net.sf.ehcache : ehcache Optional jar 2.8.0
org.apache.commons : commons-lang3 Optional jar 3.2.1
org.apache.tomcat : tomcat-jdbc Optional jar 7.0.50
c3p0 : c3p0 Optional jar 0.9.1.2
com.jolbox : bonecp Optional jar 0.8.0.RELEASE
org.vibur : vibur-dbcp Optional jar 1.0.0
org.vibur : vibur-object-pool Optional jar 1.0.0
com.googlecode.concurrentlinkedhashmap : concurrentlinkedhashmap-lru Optional jar 1.3.2
org.springframework : spring-core Optional jar 4.0.2.RELEASE
org.springframework : spring-orm Optional jar 4.0.2.RELEASE
org.springframework : spring-beans Optional jar 4.0.2.RELEASE
org.springframework : spring-context Optional jar 4.0.2.RELEASE
org.springframework : spring-jdbc Optional jar 4.0.2.RELEASE
org.springframework : spring-aop Optional jar 4.0.2.RELEASE
org.springframework : spring-aspects Optional jar 4.0.2.RELEASE
org.springframework : spring-tx Optional jar 4.0.2.RELEASE
org.springframework : spring-expression Optional jar 4.0.2.RELEASE
org.springframework : spring-test Optional jar 4.0.2.RELEASE
aopalliance : aopalliance Optional jar 1.0
org.aspectj : aspectjweaver Optional jar 1.7.4
org.aspectj : aspectjrt Optional jar 1.7.4
org.jvnet.opendmk : jmxremote_optional Optional jar 1.0_01-ea
org.apache.derby : derby Optional jar 10.10.1.1
cglib : cglib-nodep Optional jar 3.1
dom4j : dom4j Optional jar 1.6.1
org.jboss.logging : jboss-logging Optional jar 3.1.0.GA
org.jboss.spec.javax.transaction : jboss-transaction-api_1.1_spec Optional jar 1.0.1.Final
antlr : antlr Optional jar 2.7.7
org.javassist : javassist Optional jar 3.18.1-GA

Project Modules

There are no modules declared in this project.

HIT: A Hibernate quickstart

HIT - Hibernate Induction Trigger - is a library intended to provide all the configuration and dependencies necessary to begin implementing a stand-alone database-backed Spring/Hibernate application, enabling logging, JMX control, transactional boundaries and second level caching. The example code demonstrates the use of the library; a prototype Spring/Hibernate application can be developed in minutes. A Java 6 runtime (minimum) is required.

HIT on G+

Version 1.2 - released 14/03/14

  • Example code now using an embedded Derby database requiring no database setup by the user.

Version 1.1 - released 5/03/14

  • Data source connection pools are now specified by the first few characters of the AbstractDataSourceCreator implementation. Custom creators can easily be added.
  • AbstractDao now defines byIdRef vs. byId - the former lazy loads the non-key properties while the latter loads all entity properties.

Usage

The steps involved to create a HIT-based application are as follows:

  1. Choose your database vendor, database driver, database name, user etc. and create a blank database

  2. Obtain the HIT library and its dependencies via Ivy, Maven or Gradle (TBA, the artifacts will be available shortly)

  • Ivy - sample Ivy file
  • Maven:
    <dependency>
      <groupId>com.github.mrstampy</groupId>
      <artifactId>hit</artifactId>
      <version>1.2</version>
    </dependency>
  1. Create a Hibernate entity
  1. Create a subclass of AbstractDao for the entity
  1. Create a subclass of AbstractSpringInitializer and any Spring configuration classes necessary
  1. Edit the configuration files and run the application.

Configuration

Four configuration files are necessary to use HIT and must be available on the classpath:

https://github.com/mrstampy/hitman/tree/master/hitman/config https://github.com/mrstampy/hitman/tree/master/hitman/example.config

  1. hit.properties - defines hit-specific properties and can be appended to to add application specific properties.

  2. hibernate.properties - defines Hibernate-specific properties

  3. ehcache.xml - configuration for EhCache second level caching

  4. logback.xml - configuration for logging

DataSource

Included in the distribution are four implementations of a DataSource JDBC connection pool:

To switch between the four change the value of the property 'data.source.creator.type' in hit.properties. Once a connection pool has been chosen for your application the other CP jar dependencies can be excluded from the application build.

*Tomcat JDBC uses the JULI logging framework. There is no official juli-over-slf4j jar file, however adding the classes from https://github.com/pellcorp/juli-over-slf4j to your application will enable logging for this connection pool.

DataSource Configuration

For simple, low to medium volume data access typically 6 properties are of importance when configuring a datasource:

  1. The JDBC driver class
  2. The JDBC URL to the database
  3. The username for the database
  4. The password for the database
  5. The maximum number of connections the datasource can pool
  6. The minimum number of connections in the pool when idle

As each datasource implementation varies in its configuration API, the value of these properties are set via the values in 'hibernate.properties' (the first four) and 'hit.properties' (the last two). Should greater configuration control be required a datasource-specific properties file can be made available on the classpath and specified by the 'datasource.property.file' property in 'hit.properties', with the exception of the first four properties which are always set from 'hibernate.properties' values.

Versions

Version
1.2
1.1
1.0