• Home
  • RSS Feed
  • Log in

Posts Tagged ‘Hibernate’

Maarten Winkels

Why did Hibernate update my database?
Posted by Maarten Winkels in the early afternoon: April 6th, 2009

Hibernate is a sophisticated ORM framework, that will manage the state of your persistent data for you. Handing over the important but difficult task of managing persistent state of your application to a framework has numerous advantages, but one of the disadvantages is that you sort of lose control over what happens where and when. One example of this is the dirty checking feature that Hibernate provides. By doing dirty checking, Hibernate determines what data needs to be updated in your database. In many cases, this feature is quite useful and will work without any issues, but sometimes you might find that Hibernate decides to update something that you did not expect. Finding out why his happened can be a rather difficult task.
(more…)

Share

Tags: dirty checking, Hibernate, StaleObjectStateException, versioning
Filed under General | 9 Comments »


JPA implementation patterns: Data Access Objects
Posted by Vincent Partington mid-afternoon: March 9th, 2009

The JPA, short for Java Persistence API, is part of the Java EE 5 specification and has been implemented by Hibernate, TopLink, EclipseLink, OpenJPA, and a number of other object-relational mapping (ORM) frameworks. Because JPA was originally designed as part of the EJB 3.0 specification, you can use it within an EJB 3.0 application. But it works equally well outside of EJB 3.0, for example in a Spring application. And when even Gavin King, the designer of Hibernate, recommends using JPA in the second edition of Hibernate in Action, a.k.a. Java Persistence with Hibernate, it’s obvious that JPA is here to stay.

Once you get over your fear of annotations ;-) , you find that there is plenty of literature out there that explains the objects and methods within the API, the way these objects work together and how you can expect them to be implemented. And when you stick to hello-world-style programs, it all seems pretty straight forward. But when you start writing your first real application, you find that things are not so simple. The abstraction provided by JPA is pretty leaky and has ramifications for larger parts of your application than just your Data Access Objects (DAO’s) and your domain objects. You need to make decisions on how to handle transactions, lazy loading, detached object (think web frameworks), inheritance, and more. And it turns out that the books and the articles don’t really help you here.
(more…)

Share

Tags: Hibernate, JPA, JPA implementation patterns, Spring
Filed under Java, JPA, JPA Implementation Patterns | 58 Comments »

Maarten Winkels

Hibernate and Multi-Threading
Posted by Maarten Winkels late at night: February 7th, 2009

When you use Hibernate for ORM and come across some functionality that requires multi threading, there are many pitfalls that might make life difficult for you. This blog will focus on those problems. Conclusion is: don’t use hibernate managed objects in multiple threads.
(more…)

Share

Tags: Hibernate, lazy initialization exception, lost update, multi threading, transaction
Filed under General | 10 Comments »


Clean Code vs. Implementation Patterns
Posted by Vincent Partington in the late evening: January 26th, 2009

I’ve just read Robert C. Martin’s Clean Code and Kent Beck’s Implementation Patterns back to back. I actually picked up Clean Code first because my colleagues were raving about it. But then Robert Martin’s book quotes from Kent Beck’s book on the third page of the first chapter already, and disagrees with the quote, so I decided it’d be fun to read Implementation Patterns too. :-)
(more…)

Share

Tags: Hibernate
Filed under Architecture, Java, Testing | 13 Comments »


Maybe annotations aren’t that bad after all
Posted by Vincent Partington at around evening time: January 19th, 2009

Two years ago I blogged about annotations and that I considered them to be A Bad Thing. It seems I will have to eat my words. I am actually using them to the hilt in my current project.

We use JPA and specific Hibernate annotations on our entities. See for example these annotations on a field:
@OneToMany(mappedBy = "changePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@org.hibernate.annotations.Sort(type = org.hibernate.annotations.SortType.COMPARATOR,
    comparator = PositionableComparator.class)
private SortedSet steps = new TreeSet(new PositionableComparator());

(more…)

Share

Tags: Hibernate, Spring
Filed under Java | 5 Comments »

Jeroen van Wilgenburg

Sorting and pagination with Hibernate Criteria – How it can go wrong with joins
Posted by Jeroen van Wilgenburg mid-morning: December 11th, 2008

Lately I ran into an annoying problem with Hibernate. I tried to do pagination on a query result which was doing an SQL-JOIN under the hood. The query before paging returned about 100 results. When I turned on paging (with 20 results per page) all the pages had less than 20 results!
The reason for this is that with a JOIN there can be duplicate results and those results are filtered out after pagination is done. In this blog I will explain how to solve those problems and it also a cleaner way to build your Criteria queries.
(more…)

Share

Tags: criteria, Hibernate, pagination
Filed under Java | 12 Comments »

Maarten Winkels

Spicefactory – Part 2: Add Pimento to your Grails dish!
Posted by Maarten Winkels terribly early in the morning: December 11th, 2008

This second part on Spicefactory will delve into the details of writing a Grails plug-in for this framework. Be prepared to read a lot of code!

(more…)

Share

Tags: AS3 EntityManager, Flex, Grails, grails-flex-webtier plug-in, grails-spicefactory plug-in, Hibernate, JPA EntityManager, pimento, spicefactory
Filed under General | No Comments »

Maarten Winkels

Spicefactory – Part 1: Spice IT up, with Parsley, Cinnamon and Pimento
Posted by Maarten Winkels in the late evening: December 8th, 2008

In my article on InfoQ I’ve looked into how Grails and Flex can be combined to create a rapid application development platform. I think this is one of the most promising combinations for RIA development at the moment. The Flex space is very happening and there are many initiatives going on. A few days ago I encountered this one on the web: http://www.spicefactory.org/. Apart from the funny name, I think it is a very interesting initiative, because it brings some new concepts to the Flex remoting mix.

(more…)

Share

Tags: cinnamon, EntityManager, Flex, flex integration, flex remoting, Grails, Hibernate, JPA, parsley, pimento, spicefactory
Filed under General | 6 Comments »

Maarten Winkels

Confusing Hibernate Configuration Syntax
Posted by Maarten Winkels in the early afternoon: October 21st, 2008

Today I spend some hours trying to fix a hibernate bug in our application. I changed the configuration just a little and it seemed that Hibernate was unable to handle this. I’d even found a bug report in Hibernate JIRA that described the same situation. I was on the brink of downloading the sources and trying to fix the problem in Hibernate… turns out there was an error in our configuration! This is to say, the model we wanted to configure could be configured in a non straight forward way. Apparently from the JIRA issue there are more people that find it difficult to come up with the correct configuration for this situation. Let me try to help them with a little example.

(more…)

Share

Tags: bi-directional association on join table, ConstraintViolationException, Hibernate, SQLException Column not found, SQLGrammarException could not load an entity
Filed under Java | 2 Comments »

Maarten Winkels

Configuring Hibernate and Spring for JTA
Posted by Maarten Winkels mid-afternoon: July 18th, 2008

Spring is a great framework for dependency injection and it comes with a lot of support classes and utilities for all kind of things. Hibernate is a persistence service with a lot of useful features, that is relatively easy to use. Configuring both frameworks is not always easy. Configuring them together is sometimes hard and it is easy to make mistakes.

This blog addresses a problem in a configuration that is fairly common: use Spring for transaction management on top of a JTA provider and use Hibernate for persistence. Transaction demarcation is easy and declarative with Spring. The problem is that Hibernate sometimes needs to detect the current transaction and this needs to be configured. This leads to hard to detect bugs in applications that rely on auto flushing.
(more…)

Share

Tags: auto flush, Hibernate, JTA, Spring
Filed under General | 6 Comments »

← Older posts
Newer posts →

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India
  • XebiCon 2012

Categories

  • Java (312)
  • Agile (192)
  • General (141)
  • Scrum (70)
  • Testing (65)
  • Architecture (65)
  • Performance (47)
  • Middleware (59)
    • Deployment (40)
  • Xebia Labs (41)
  • SOA (31)
  • Project Management (31)
  • Podcast (31)
  • Tools (28)
  • Uncategorized (24)
  • lean architecture (20)
  • Quality Assurance (19)
  • Articles (15)
  • Requirements Management (14)
  • Virtualization (21)

Tag Cloud

    Concurrency Control JPA implementation patterns product owner lean architecture Moving to India Java Flex Ajax Eclipse Oracle Xebia SOA Spring TDD Hibernate Grails Lean Javascript ACT Scala lean architectuur Architecture JPA XML Maven Agile agile architectuur Groovy Frameworks Scrum

Archives

  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
Avatars by Sterling Adventures