On Feb 10, 2011, at 8:15 AM, tjsaker wrote: > > Container managed persistence using JPA. This is just a tutorial exercise.
Excellent. FYI, the term Container-Managed Persistence (CMP) and its inverse Bean-Managed Persistence (BMP) do not apply to JPA. Both pertain only to EJB 2.x style entity beans which are almost universally hated :) They're both being removed in Java EE 7. Best not to mix them to avoid confusion, especially in interviews. Here's what I do when starting a new JPA app. Maybe some of this will be useful to you as well. I typically start with one of the examples that's closest to what I'm after. This example app has all of the basics for JPA usage in it: http://openejb.apache.org/3.0/injection-of-entitymanager-example.html Though this is the one I tend to start with the most because I like the test case injection support and to setup test data in the testcase setUp() method: http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1.4/examples/testcase-injection I'm very lazy so I tend to grab that app and just start changing things. A little faster than starting from scratch. For me at least. You could grab it, rename the Movie entity to Library and make your changes that way, bit by bit. There are some things I explicitly avoid until later: - A separate or shared database (use an in memory db that does not write to disk) - Explicitly specifying table definitions (all jpa implementations are fully capable of creating 100% of the required schema) - @Remote interfaces or serialization (use @Local interfaces, serialization is tricky) - Deploying to a standalone EJB server (embedded ejb container development is *much* faster) - non-default locking (steer clear of specifying locking and use the defaults) I typically wait till I get something basically working. Once I'm happy with my progress, then I will add in the things I need from the above one at a time so that when things fail (and they will) I know where to look. Doing all at once and from the start will make you want to pull your hair out :) This last document here is pretty good as well. I wouldn't dig into it now as it isn't at all a "getting started" kind of document, but it is pretty good once you're more familiar with the moving parts of JPA and you want to know "how does all this stuff *really* work?" http://openejb.apache.org/3.0/jpa-concepts.html Hope any of the above helps! Happy learning! -David
