Showing posts with label transactional. Show all posts
Showing posts with label transactional. Show all posts

Wednesday, 8 July 2009

Hibernate and JPA

I've been posting responses to various queries on the Hibernate Forums lately.

There seem to be a few recurring queries, so I'm looking to put together a white paper of sorts.

Here are my thoughts of what this might include.

JPA versus Hibernate:
- Standards compliant versus proprietary
- EntityManager versus Session

JPA does not require EJB3
- using a JPA implementation does not necessarily require an EJB3 container

JPA implementations:
- Hibernate
- DataNucleus (formerly known as JPox)
- Eclipselink
- OpenJPA
- Toplink
- ...?

Things to consider when evaluating products for your product or project:
- Licensing
- Stability
- Documentation and support
- Performance
- Benchmarking that matches your system's likely use cases
- Cost

JDBC Connection pooling
- Avoiding stale connections
- Implementations:
- c3p0
- DBCP
- Spring / Tomcat
- ...?

Lazy initialisation
- collections

Proxies


XML versus Annotation based configuration


Transactions
- Annotations for declaring Transactional behaviour of methods
- Which methods in which classes to mark with transactional annotation

Caching
- Second level cache
- Query cache
- Session / EntityManager

Performance issues
- N+1 queries
- batch size

Coding considerations:
- lazy initialisation exceptions
- avoid use of instanceof operator when proxies may be in place

Friday, 12 June 2009

Declaring directives in Grails

I thought that I may have been missing some subtle aspect about programming in Groovy when I noticed some code that was trying to specify the transactional behaviour of a service.

According to the Grails documentation the way to specify this is by including a static variable named transactional and set it to true or false.

The default behaviour (without the existence of this static variable) is true.

In a number of cases, including the 2nd edition of The Definitive Guide to Grails I didn't see the static keyword preceding the transactional variable name (I've submitted errata for the offending code snippets).

In the world of Java development, I would hope that my IDE would pick up cases where it appeared as though I had made a simple error. Can anyone out there advise me of whether this sort of thing is being included in the development of the various plugins for IDEs at the moment?