Posts Tagged ‘persistence’
Sunday, June 16th, 2013
I really love Arquillian to run integration tests for my Java EE applications – especially when running on different containers – and I also love the Arquillian tool stack from Arquillian Drone to the Arquillian Persistence Extensions.
Today I’d like to share a short snippet how to achieve transaction rollbacks when testing an EJB in combination with Arquillian and the Arquillian Transaction Extension…
(more…)
Tags: arquillian, ejb, java ee, jee, jpa, persistence, rollback, testing, transaction
Posted in Enterprise, Java, testing | No Comments »
Sunday, April 14th, 2013
One common question that you may encounter one day when using object-relational-mapping in your application is how to slim down data that you’re retrieving from the persistence layer down to a specific subset for your use-case in an efficient manner and without using complex additional mapping frameworks. In some situations you might declare lazy loaded fields but another approach that I’d like to share with you here are JPA2 constructor expressions.
Constructor expressions allow us to create plain old java objects from the result of an JPA query. The advantage is that we may use different projections for different scenarios and without being managed, the POJOs might help us save some resources here.
In the following tutorial, we’re going to persist 100 book entities with multiple properties to an embedded database and we’re using constructor expressions afterwards to create smaller POJOs using a subset of the information available from each persisted book.
(more…)
Tags: criteria api, criteria builder, eclipselink, Java, jpa, jpql, maven, memory, persistence, projection, xml
Posted in Java | No Comments »
Monday, February 25th, 2013
The ability to attach lifecycle events to an entity using simple annotations sometimes is a neat feature in the Java Persistence API.
The following short snippets demonstrate how to bind and trigger the different available lifecycle events using an embedded derby database and a bunch of annotations.
(more…)
Tags: entitylistener, entitymanager, hibernate, java persistence api, jpa, orm, persistence
Posted in Development, Java, testing | No Comments »
Monday, March 26th, 2012
In today’s tutorial we’re exploring the world of faceted searches like the one we’re used to see when we’re searching for an item on Amazon.com or other websites. We’re using Hibernate Search here that offers an API to perform discrete as well as range faceted searches on our persisted data.
(more…)
Tags: discrete, entity, example, facet, hibernate, jboss, jpa, lucene, persistence, range, search, tutorial
Posted in Java | No Comments »
Sunday, February 5th, 2012
Often we’re writing an application that has to handle entities that – on the one side need to be persisted in a relational database using standards like the Java Persistence API (JPA) and using frameworks like Hibernate ORM or EclipseLink.
On the other side those entities and their fields are often stored in a highspeed indexer like Lucene. From this situation arises a bunch of common problems .. to synchronize both data sources, to handle special data mapped in an entity like an office document and so on..
Hibernate Search makes this all a lot easier for us as we’re hopefully going to see in the following short tutorial…
(more…)
Tags: annotation, hibernate, index, jpa, lucene, orm, persistence, query, term
Posted in Java | 2 Comments »
Monday, October 11th, 2010
Today we’re going to take a look at the world of object-relational Mapping and how it is done using the Java Persistence API by creating some basic examples, mapping some relations and querying objects using JPQL or the Criteria API..
(more…)
Tags: annotation, criteria api, eclipselink, example, hibernate, javadb, jee, jpa, jpa2, jpql, jsr-317, junit, mercurial, orm, persistence, toplink, tutorial
Posted in Java | No Comments »
Tuesday, April 6th, 2010
They built a nice new feature in Grails 1.2 called “named queries“. Named queries can be defined in a domain class as static properties and support the criteria builder syntax. (more…)
Tags: criteria builder, gorm, grails, groovy, hibernate, named queries, persistence
Posted in Development, Groovy/Grails | 2 Comments »