java - Hibernate or JPA or JDBC or? -


i developing java desktop application have confusions in choosing technology persistence layer.

till now, have been using jdbc db operations. now, learnt hibernate , jpa still novice on these technologies.

now question use java desktop application following?

  • jpa

  • hibernate

  • jdbc

  • dao

  • any other suggestion you...

i know there no best choice them , totally depends on complexity , requeirements of project below requirements of project

  1. it's not complex application. contains 5 tables (and 5 entities)
  2. i wan't make code flexible can change database later easily
  3. the size of application should remain small possible have distribute clients through internet.
  4. it must free use in commercial development , distribution.

==================================== edited =======================================

on basis of below answers, go jpa prevent myself writing vendor-specific sql code.

but have problems in jpa mentioned @ java persistence api

here's take:

  • jpa: agnostic way java persistence without coupling clients hibernate, toplink, etc.
  • hibernate: choice if have object model map to.
  • jdbc: java persistence built on this. lowest level
  • dao: more of pattern technology; crud operation interface.
  • ibatis: halfway between jdbc (raw sql) , hibernate (orm).
  • jdo: java data objects, specification java persistence. (e.g., apache jdo)

it's not complex application. contains 5 tables (and 5 entities)

any of these work, jdbc simplest. others built on top of jdbc.

i want make code flexible can change database later easily

schema changes have similar effects in technologies.

the size of application should remain small possible have distribute clients through internet.

using jpa or hibernate require jars add size of deployment. jdbc minimize this.

it must free use in commercial development , distribution.

see licenses of technologies. shouldn't problem of them.

fyi: it's possible write generic dao interface:

package persistence;  import java.io.serializable; import java.util.list;  public interface genericdao<t, k extends serializable> {     t find(k id);     list<t> find();     list<t> find(t example);     list<t> find(string queryname, string [] paramnames, object [] bindvalues);      k save(t instance);     void update(t instance);     void delete(t instance); } 

if objects map 1:1 5 tables, i'd jpa overkill squared.

is app on order of 3mb jar? if no, hibernate or jpa more double size. can quantify how much. , there's more 1 jar, because both have dependencies.

yagni says should keep simple. it's 5 tables!

changing vendor, if properly, means switching jdbc driver jar, changing driver class name, , adding new connection url - have no matter technology pick.

i find databases don't change radically. you'll change schema, entire vendor? not likely, if have several clients. it'll major inconvenience make user base switch databases.

which 1 planning ship with? hsql or require installation mysql? that's more pertinent concern.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -