OR-Mappers and existing databases, or Active Records vs. JPA

The question whether to use a reflective framework like "Active Record" or DataSet, or something like JPA is discussed over and over again (by the way in every new project). Both approaches are very effective, but depend on your specific project context. Regardless what you are doing you have to set one master: either the database, or the objects.

Maintaining both in parallel is not very efficient. I never created the OR-Layer in Java from scratch in case the database already existed. Either you can use tools like middlegen or even free and opensource IDEs can provide this for you. In Nebeans 5.5/6 just create a datasource and then right-click on your project and choose "Create entities from existing databases" and all JPA-Entities will be created (with relations) etc. for you. By the way the generated code is really clean.

JPA has a huge advantage - it is typesafe, objectoriented and very good to maintain. The cool story here: you can test your JPA-persistence with an usual unit-test - outside the server. At the other hand DataSet-oriented frameworks are more effective for the realization of CRUD interfaces - even the UI can be generated using the metadata.

In fact in bigger projects it is better to use DataSets and OR-Mappers in parallel. So complex business logic ist still good to maintain and CRUD-usecases can be easily implemented. ...and JDBC 4.0 could change the (persistence) world again...

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License