I want to create and maintain a relatively simple relational database in my java app, to save info between web sessions, and do SQL-like queries on. I have read up on JPA, Hibernate, Eclipselink etc – none seem all that simplistic. What’s the simplest option to get up and running?
Share
If you do not want to use an ORM (which are necessarily complex since they are generic and need to cover a lot of cases), you have quite a few choices if you are willing to look at non-relational,
The historical relational solution: do it yourself by mapping your object properties to table columns and calling the DB through the JDBC layer. It cannot be much faster and efficient but is the hardest to maintain. Spring JDBC may ease your pain.
If you do not really care about doing elaborate queries: serialize your object using Java serialization or a framework like Kryo (fast), XStream (xml) or Jackson (json) then save your blob/properties to the DB. You may actually look at a non-SQL db to store this very efficiently, like CouchDB
A (very hype :-)) NO-SQL like serialization: serialize to JSON and store in MongoDB or serialize to XML then store in DB2 or MS-SQL in XML columns or in a native XML server like eXist. All these DBs provide query languages on the stored object: