Using configurable XML / annotations is supposed to make persisting data to DB easy
Hmmmmm. Is that what it's for? My Powerbuilder/Sybase developers would disagree. They'd rather just write SQL and plug it into Powerbuilder. Now they need to learn Java, and objects, and all that other stuff. Does it make persisting data easy? Maybe, if you're a Java developer.
I'd say that it allows Java developers who understand objects to approach their database in a more object-oriented way - a way that is much more natural for them. Furthermore, there is a great buffer between the database code and the Java code, so that changes in the data layer only require a small change in the mappings, not changes in the SQL that was embedded in the code.
Here's a thread you might find interesting. It's all about why we need a framework like JPA or Hibernate or EJB3 or whatever...
As far as distributed transactions go, you can allow the EJB container to manage the transactions. As such, so long as you are using XA drivers that can participate in two-phase commit semantics, the container will take care of the distributed transactions.
These are good questions. I wouldn't characterize them as "immature thoughts ."
Joined: Jun 19, 2008
Thanks Cameron - I did go through the link .
Still working on the mapping examples and thanks for all the examples you have posted .
I still have a couple of questions ::
1 > Looks like JPA does not support One to Many Unidirection Mapping .
Let me explain ::
From the DB model :: Have a Master table and a child table Foreign key resides in child table
There will be multiple children belonging to the same parent .
From the OO model :: Parent class and Child class Parent class contains a "Set" attribute which will contain the "Child" Objects
This is unidirection ( from Parent >> Child )
Now I want to ensure that when I save the parent the child gets saved too