Skip to main content

Persistence API : JDO or JPA ?

http://www.datanucleus.org/products/accessplatform_2_0/persistence_api.html
There are two standard API's for persistence - Java Data Objects (JDO) and Java Persistence API (JPA). The former (JDO) is designed for all datastores, and the latter is designed for RDBMS datastores only. When choosing the API to use in your application you should bear the following factors in mind
  • Target datastore : JDO is designed for all datastores, whereas JPA is just designed around RDBMS and explicitly uses RDBMS/SQL terminology. If using RDBMS then you have the choice. If using, for example, an ODBMS then JDO makes much more sense
  • Datastore interoperability : are you likely to change your datastore type at some point in the future ? If so you likely ought to use JDO due to its design
  • API : both APIs are very similar. JDO provides more options and control though for basic persistence and retrieval there are differences only in the namings
  • ORM : JDO has a more complete ORM definition, as shown on Apache JDO ORM Guide
  • Experience : do your developers know a particular API already ? As mentioned the API's themselves are very similar, though the metadata definition is different. Remember that you can use JPA metadata with the JDO API.
  • Querying : do you need a flexible query language that is object-oriented and extensible ? JDOQL provides this and the implementation in DataNucleus allows extensions. If you just want SQL then you can use JDO or JPA since both provide this

Comments

Popular posts from this blog

Running and debugging jetty maven plugin in Netbeans

Coding with Netbeans will make developer life simple. We don't need search for plugins and install different plugins from different places. Maven projects can opened as directly in Netbeans without any settings. Here is the way to run & debug using maven jetty plugin. We can't add Jetty server as servers in Netbeans. Run project: Right click on project and open the properties. click on "Actions" on left side. On right side there will be list of available actions.  To run jetty can be created a new action or override default "Run Project" Here I am overriding default one, Because I can run the project just by hitting "F6" key click on "Run Project" Enter the value "Execute Goals" as "jetty:run", If you want run as offline add "jetty:run -o" "Active Profiles" can be empty In "set Properties" field we can set like skip test. Here I am skipping test. Done, After setting y...

Disable hibernate Optimistic Lock for specific scenario

Optimistic Lock gives more control on concurrent modification on data. That can be achieved very easily in hibernate using @Version column. But in some cases we may have to avoid concurrency check, example background process. To disable Optimistic lock set OptimisticLockMode as NONE for entity class while hibernate is initiating. We can't remove version column that needs Database changes and ORM changes. In this way we can disable Optimistic Lock by code. implement "org.hibernate.event.Initializable" interface override the below method.     @Override     public void initialize(Configuration cfg) {         Iterator<?> persistentClassIterator = cfg.getClassMappings();         while (persistentClassIterator.hasNext()) {             PersistentClass persistentClass = PersistentClass.class.cast(persistentClassIterato...

unlock the static files while jetty is running on windows.

When running a java maven web application  in jetty on windows. All static files are locked and not able edit and save those files while jetty is running. This will eat developers time beacuse each and every change in javascript & css files, jetty have to re-started. Depends on application's dependencies that build will take more than 5minutes. Why jetty is locking the static files? Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file Jetty provides a configuration switch in the  webdefault.xml  file for the  DefaultServlet  which enables or disables the use of memory mapped files. If you are running on Windows and are having file locking p...