Showing posts from February, 2014

Java DB queries - All of the Options (2014)

When you want to query a DB in java, you have two main options to go: 1. Straight forward queries to the DB This is the most intuitive (imho), just write down the query you want and get the results from the DB. The most notable downside to this method is that you pollute your code with sql queries which can be all over the code, so there is no "one point of change" to the queries, which makes it very hard to change the DB schema for example. 2. ORM style queries This way requires more work to begin qurying the DB but then you use java objects instead of queries so you keep your code clean. You also are able to separate your model from your controller thus change your DB schema with much less pain. Which ORMs exist? Many, while the most notable ones are hibernate (which was the first afaik) & eclipse/total link. But most ORM are not only a third party library (like hibernate when it began) but are now part of JEE implementation of the