Breeze JS has an EntityManager that queries entities from the server, keeps them in cache, keeps track of the state of each entity, and saves the changes to the server when requested.
Breeze Java (breeze.server.java) is a server-side library that works with Hibernate/JPA to manage persistence for Breeze client applications. It turns Breeze queries into Hibernate/JPA queries, and saves changes to the database using Hibernate/JPA.
The Breeze server is designed to be stateless. A Hibernate Session/JPA EntityManager is created to handle each query or save request, but then discarded. No long-running transactions, detached objects, or disconnected sessions are required. Entity state is kept on the client, not the server.
Breeze clients do not require a Breeze server; for example, BreezeJS will also work with existing RESTful APIs. The full power of Breeze comes with supporting the three types of client-server communication.
Breeze client applications make three basic kinds of AJAX calls:
The breeze-hibernate library runs on the server and uses Hibernate to handle each of these requests.
The Breeze client requires metadata about the entity model in order to know the data types and relationships of the entities. The breeze-hibernate library uses the Hibernate metadata API to extract this information from the application’s Hibernate configuration. It creates a data structure that is serialized to JSON and returned to the Breeze client.
The Breeze client has a powerful query language that can send a variety of queries to the server. These queries are sent to the Java server in JSON format. The breeze-hibernate library converts these queries into Hibernate Criteria queries to query the database.
The query results, a collection of entities or graphs of entities, are serialized to JSON and returned to the Breeze client.
The Breeze client performs saves by sending an array of entities to the server as JSON in a POST request. The entities in the array are separate, i.e. not arranged in a graph. The breeze-hibernate library re-connnects the relationships between the entities, adds them to a Hibernate Session (in the appropriate order) as a save, update, or delete, and commits all the changes in a single transaction.
See the Getting Started page to start using Breeze.