Trying to work on Many to Many and am confused. I agree I dont as yet understand the details but after trying out the various mappings - my initial take is .......... ( Used to working on JDBC )
1 > Using configurable XML / annotations is supposed to make persisting data to DB easy
Working with the relations I feel JDBC works well I do need to write plumbing code - but its out in a jiffy
2 > JPA in EJB3 consists of using any suitable provider ( Hibernate / Toplink etc ) Does JPA take care of distributed Tx or is that something that is provided by the EJB container ?
I know these are basic questions but wanted to vent my immature thoughts .
Thanks , ~satish
Post by:Cameron Wallace McKenzie
author and cow tipper
Originally posted by satish bodas:
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 ."
Post by:satish bodas
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