Hibernate Spatial extension together with Spring running on a Tomcat
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).
There is a huge difference when you work on a personal project and when you work on an enterprise project. In your personal project it doesn’t really matter how you structure the code – the goal is to get it to work and everything else comes in second row. In an enterprise project you don’t know how long you are going to work on the project, who is going to take over, will it be send to India, etc. In an enterprise project you are not a one-man army but a team and the team members will be replaced many times over the projects lifespan. Therefore you need a common ground – a paradigm that state how members in the team should behave, what a new team member should expect and especially what is expected of a member of the team when contributing to the project. Continue reading →
How to build a domain model with JPA2 and Hibernate
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 →
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 →