Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
1. when calling the cmr method parent.getMessages(), I get an empty collection - where are my message entities?. They exist in the DB and my deployment descriptor *supposeably* defines a relationship.
(currently, I just call a finder on the child home entity and this works - but its not cmr!!)
2. do I have to "add" each child to the parent? (eg parent.getMessages().add(child) ?
what does this do?, or better what is the container doing?
3. when I try to "add" I get the following error: java.sql.SQLException: ORA-00936: missing expression
4. Most examples I have found show how to "get" the collection/related entities but dont show means for managing the relationship (eg updating, creating, removing)
5. I have read somewhere that the container creates a table in the database to manage relationships - is this true? Although my app deploys successfully, there is no "extra" table in the database.
6. In general, I assume you should just be able to get your parent entity (findByPrimaryKey) and call the get..() method returning a collection, so why the need to "add" the child in the first place.
Can someone please shed some light? and advise what the sql exception could be due to. I am happy with the ejb-jar.xml <relationship> - looks OK to me and pretty simple - so I can only think its my orion-ejb-jar.xml which is wrong.
In my project I have the same kind of relationship between NewsProvider and NewsSource. Your ejb-jar.xml should contain something like:
To manage the CMR, you have indeed to set one of the CMR fields. Dependiing on whether the relationship is unidirectional or bidirectional (like mine), you will have one or two fields. In my exmaple, you can set (or add to) the newsSource collection or set the newsProvider field. Here is an extract from NewsProviderBean, corresponding to your batch entity:
For a one-many relationship like yours and mine, there is no need for an extra table in the database, but there would be one for a many-many relationship.
As for the SQl exception, I have no clue... Hope it helps.
Bruno Collet<br /><a href="http://www.practicalsoftwarearchitect.com" target="_blank" rel="nofollow">www.practicalsoftwarearchitect.com</a><br />- The Paradox of Software Architecture: It is easy to make a complex architecture, but it is difficult to make a simple architecture.
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss