Joda-Time provides a complete quality alternative to the JDK date and time classes. At some point however, many projects need to persist these classes to a database. One popular tool for achieving this is Hibernate.
To ease the integration of Joda-Time and Hibernate, this sub-project was setup. It aims to provide the classes necessary to persist Joda-Time objects.
jBPM (Java Business Process Management) is an open source Java framework for managing workflows.
This project provides:
* A simple standalone Eclipse project for checkout and experimentation
* Example jBPM integration with Hibernate, Spring, and Oracle XE (a free download)
* Simple JUnit tests for leaning by doing
* A companion powerpoint presentation in the downloads section
* How-Tos in this Wiki
For application development we use spring and hibernate. For rapid application development there are many pitfalls around. Our mission is to provide a framework that handles all default settings and allows us to quickly start with the development tasks our customers are interested in. So the framework tries to support you by:
* Providing a maven based development environment which uses a proven dependency configuration for fast composition of a working base setup.
* Several utilities were needed during application development extending functions from other utility libraries, e.g. Apache commons.
* Providing a module concept for easy setup and extension of a base application
* Providing reusable and extendable components for common tasks such as application setup, user management, security, history and reporting.
* Providing a base UI implementation based on JSF/MyFaces/MyFaces Trinidad
Where to start
For starting have a look at the quick start tutorial. Within this tutorial a small database application is developed using the most important features provided by the framework.
This article demonstrates a brand new open source library for unit testing, called Unitils. Unitils helps you in writing simple and maintainable unit tests with JUnit or TestNG . It glues together some widely used test libraries like DbUnit and EasyMock and offers integration with Spring and Hibernate . Unitils encourages applying good practices and unit testing guidelines. The ideas behind the code are based on the authors' concrete experience on enterprise projects.
Unitils offers following features
* Equality assertion through reflection, with options like ignoring Java default/null values and ignoring order of collections
* Support for database testing involving test data management with DbUnit, automatic maintenance of unit test databases and automatic constraints disabling
* Hibernate integration features such as session management and testing the mapping with the database
* Integration with Spring, involving ApplicationContext management and injection of spring managed beans
* Integration with EasyMock and injection of mocks into other objects
Very interesting approach!
"Apache Empire-db is an Open Source relational data persistence component which allows database vendor independent dynamic query definition as well as safe and simple data retrieval and updating. Compared to most other solutions like e.g. Hibernate, TopLink, iBATIS or JPA implementations, Empire-db takes a considerably different approach, with a special focus on compile-time safety, reduced redundancies and improved developer productivity."
With the addition of generics in Java 5, writing a custom DAO for each domain object is no longer required. There are a wide variety of articles on creating generic DAOs, but my current project uses the approach from this IBM DeveloperWorks article. This approach was choses mainly because of the clearly written article and the integration with Spring. You should be able to extend any generic DAO based on Spring to implement the stored procedure configuration.
Many enterprise business applications have such requirements that they should log their users' operations; who performs and when, records that are inserted into, deleted from database, or are changed during those operations, with a meaningful description about current state of those records. Hibernate already provides an interceptor mechanism at SessionFactory level. Hibernate fires events indicating new records are inserted, old ones are deleted, detection of updates, and other events related with transaction status, session flush etc. By that way one can easily track changes on persistent entities in his application.
Nice example on how to get rid of superfluous code... The following implementation of equals, hashcode and toString is using the concept of one or more business keys defined by annotations.The annotation @BusinessKey can be applied with an include/exclude filter on field or method level.
Hibernate saveOrUpdate trap for web developers and StaleStateException
Summary: Hibernate users should be aware of saveOrUpdate method if they continue to use the same persistent object even if a transaction failed at some point.
Details:
Suppose you have a persistent object bound to your web(like JSF) views. Entered some data (which will lead to a db ConstraintViolationException) and tried to save it (at your DAO service) by using saveOrUpdate method. As we expected, it will throw a ConstraintViolationException and you'll rollback the transaction.
Then, go back to the entry page, correct the wrong field value at the same object, and try to save it again. You'll get a StaleStateException since saveOrUpdate method assigned identifier values automatically to your new object when you attempt to save it first. Later, when the save operation failed, it didn't roll back your object's state to its initial state. The summary of the flow causing this error is as below;
This article presents with an solution on how to page through large amountsofdata effectively without taking down your database and without keeping it all in memory.
In spite of the example working, transaction management is not working appropriately when it comes to both Hibernate and JBossCache participating of the same transaction. The reason is because at the time of writing this wiki, Hibernate did not allow to inject a JTA Transaction Manager which is not bound to JNDI. In the example, Hibernate creates a JDBC transaction and JBossCache a JTA transaction which are not linked together. To be able to make a Hibernate and JBossCache participant of the same JTA transaction in a standalone environment, customer code needs to be added to Hibernate to get around the JNDI/JTA coupling.
EclipseWork is a powerful code generation plugin for Eclipse. You can easily generate code using POJO's or Tables from the database.
EclipseWork takes care of all the complexity in creating Eclipse Wizards. You don't need to be an Eclipse developer to write powerful wizards. Enjoy!
PathProxy is a design pattern for persisting complex relationships without cluttering up your database. In this article JavaWorld contributor Matthew Tyson introduces his PathProxy pattern and walks you through an example application implementation based on Spring, JSF, and JPA/Hibernate.
The Envers project aims to enable easy versioning of persistent JPA classes. All that you have to do is annotate your persistent class or some of its properties, that you want to version, with @Versioned. For each versioned entity, a table will be created, which will hold the history of changes made to the entity. You can then retrieve and query historical data without much effort.
Similarly to Subversion, the library has a concept of revisions. Basically, one transaction commit is one revision (unless the transaction didn't modify any versioned entities). As the revisions are global, having a revision number, you can query for various entities at that revision, retrieving a (partial) view of the database at that revision.
Java toolkit which makes DAO manager creating easier. It produced DAO compatible with JPA specification. It has implemented CRUD operations and some features (active, hidden, default, etc.). It also extends standard API for criteria (like Hibernate ones).
***No, no, no - needs HibernateDaoSupport! Bad! *** Another promising GenericDao framework: "Generic DAO (a.k.a generic-dao OR gendao) is a Java package which allows a developer to skip writing DAOs for their persistence objects when they are using Spring and JDBC or Hibernate. It is a lightweight ORM package without the loss of control or increase in complexity which is experienced with some of the heavier weight ORM packages.
It is designed to make it easier and faster for developers to write their DAOs without having to rewrite the same old boring save/delete/etc functions over and over for each persistent type but also not having to have implementation dependencies in their DAO interfaces. It also allows for good control over which persistent objects are usable within the DAO and is easy to extend so you can add your own DAO methods. Configuration is easily handled via spring configuration but can also be handled programmatically, however, since the package depends on the spring framework you are best off using it with spring.
Generic DAO allows a developer to write their persistent objects as POJOs with no dependencies. It supports an approach between the anemic domain model (or service/manager model) methodology and the use of a rich domain model (or heavy DDD). The use of simple POJOs as persistent objects makes it easy to swap around storage mechanisms while allowing the developer to use their model objects throughout their application and even expose them for use by other applications.
The package includes functionality for all the basic ORM CRUD type methods along with search methods and batch methods. The JDBC part of the package includes support for caching all the DAO methods (which could also be used with the hibernate part but hibernate has its own caching so you should probably use that). It also includes interceptor points for before and after all read and write methods. For simpler use cases, you can write your POJOs, make them persistent, create your DDL and not have to write a single line of DAO code. The package is built on and depends on the spring framework."
This project contains custom Hibernate and JRuby extensions to let Hibernate work directly with org.jruby.RubyObject objects. That means that the Hibernate session accepts and returns plain old Ruby objects (no intermediary Java domain classes are needed). Another goal is to provide a Rubyish interface to the Hibernate configuration and functionality.
The idea to start this project comes from Ola Bini's blog http://ola-bini.blogspot.com/2007/04/activehibernate-any-takers.html. For more details please see http://rubymatic.blogspot.com.