Category Archives: JPA

#Hibernate #Spatial #extension together with #Spring running on a #Tomcat

Hibernate Spatial extension together with Spring running on a Tomcat Print This Post

I have done a lot of projects based on Hibernate (JPA2), Spring, Tomcat (Jetty for test) and Maven (http://www.wiegand.dk/wordpress/?p=51). The basic setup is not easy – but once done correct – it can be reused in most projects afterwards.

Some years ago my company (http://northtech.dk/) moved its main focus from general software architecture to the GEO sector. Because of that we are adding the GEO perspective to all our utilities and frameworks. This article is about how to add GEO awareness to our core JAVA paradigm (http://www.wiegand.dk/wordpress/?p=51).

Continue reading

How to build a #domainmodel with #JPA2 and #Hibernate

How to build a domain model with JPA2 and Hibernate Print This Post

I have been working with enterprise system for a while and mainly as an Infrastructure Architect – The person that binds all things together to a complete working system. One of the many integrations in an enterprise system, is the internal integration from the code (domain model) to the database. This is normally called ORM (http://en.wikipedia.org/wiki/Object-relational_mapping) – Object-relational mapping. Over the many years I have worked with this, the integration of cause have evolved from a simple and direct SQL approach to gigantic automatic frameworks. This is of cause both a good and a bad thing.

This first question I normally get when talking about ORM is: What about the overhead – is it fast enough? And the simple answer is…. NO!
Continue reading

What to do about enums in Hibernate/JPA/JPA2?

What to do about enums in Hibernate/JPA/JPA2? Print This Post

To ensure the integrity in data model and domain model enumerations are a necessity!

This is my statement and let me try to explain why I think it is important and what my solution to the problem is.

In the data model even that it is not read by the domain model it is a good idea to keep the data normalized. When this is said I must in the same sentence state than I am not into deep normalizing where data in the end is more obscure than useable – meaning not accessible. The most common example is that you have an entry table and for each entry you want a status or state. This could be a transaction table with a status that states if the transaction is new or processed. Instead of just adding the status as an integer [1, 2] or string [new, processed] is it good to have the relationship as a foreign key to a status table with to entries – [1, New] and [2, Processed]. With this construction you ensure the data integrity on the database level but this is NOT a good way to handle the data in the domain model.
Continue reading