By ilevent
via fromapitosolution.blogspot.com
Published: Dec 02 2008 / 21:45
It is a fact that we need a persistence solution. Most of applications are database-driven and need to access tables, modify data. Although there are many questions about persistence frameworks, we need them a lot when developing applications. Otherwise SQL codes scatters across applications causing an ugly and unmanageable application. Persistence frameworks build a database layer and separates concerns. Java Persistence solutions are divided into two branches. One is Java standard solutions; JDBC, EJB, JDO. The other is ORM (Object-relational Mapping) frameworks; Hibernate, Toplink, Enterprise Object Framework, iBatis etc.
Let me ask the basic question that everybody somehow asks himself “Isn’t there any other solution to persistence problem simpler and more powerful?” I have been reading many problems about this issue. Last one was Sun’s attempt to simplify EJB. In fact, this is why new frameworks will never end.
Comments
Joshua.Suereth replied ago:
Although I don't agree with everything stated, this blog makes some very interesting points. Definitely worth a read for anyone using ORMs
kunnar replied ago:
Same thoughts.
ORMs have some problems, but i still like using ORMs for database access. Why write SQL manually if it can be automatically generated? Btw., worst thing i know for accessing database is using stored procedures. Because then somebody thinks that he can tune those queries and add business logic there. There are lot of people who know SQL but no real programming languages. Then you have finally some business logic in application and some in database and you have to switch context all the time. If you set breakpoint in your Java IDE and reach to db procedure call then you never know what crap it is going to do, cant step in with debugger. One thing i really like in using hibernate is that it kills such opportunities for non real developers because SQL is generated dynamically and it cant be changed easily anymore.
OtengiM replied ago:
I dont agree entirely all the points but it is a great article and some points are true, SQL is a DSL, why we need to reinvent the wheel with another similar DSL's.
jonnes replied ago:
jPersist is my answer
ilazarte replied ago:
Shout it from the top of a mountain. We need a better answer to ORM. For my latest pet project I've stripped out the usual ORM layer and have built my persistence on .sql files organized in a file hierarchy. It's amazing how much cleaner and easier everything got instantly. (yes even select * from users got its own file)
- my IDE switched to sql-dev mode when i opened the file which allows me to execute the query to test it.
- my IDE was now able to syntax check the query whereas it couldn't before in xml or java.
- it was easy to suddenly find queries in file/selections thanks to IDE file finding mechanisms
- every query had a unique name and i didn't need to come up with artificial "named queries"
- my query abstraction is the file itself- i can change from straight query on a table to a view without changing any java code...
and a host of other similar benefits.. it was like my programming environment slapped me on the head and said "duh, what were you thinking anyway!"
ilazarte replied ago:
Another point I liked was the metadata point. How much easier would everything be if current JDBC drivers actually implemented ParameterMetaData?
newton_dave replied ago:
Another answer is object databases, which didn't really seem addressed.
mknutty replied ago:
He needs to get out more and see what it really available and why. He has worked too long at one place.
mknutty replied ago:
Meant to say he is pretty much confused.
Voters For This Link (29)
Voters Against This Link (3)