EJB CMP/CMR example with JBoss+Xdoclet
In this post I’ll first discuss how to implement a unidirectional one-to-one relationship with EJBs, JBoss and Xdoclet in abstracto, using two tables called table1 and table2. Thereafter I’ll present a concrete example, illustrated with (more detailed) code excerpts.
Disclaimer: this post is not meant to advocate the use of EJBs. It is solely meant to be technically informative.
Although this excellent tutorial gently introduces Container Managed Persistency (CMP) with entity beans, JBoss, Eclipse and Lomboz , it doesn’t address Container Managed Relations (CMR), which are essential to any non-trivial application.
Moreover, once you have implemented your relations, you will get the big bonus of the container setting up your database schema, if not present already. This means that you don’t have to deal with your database specific SQL extensions anymore [ZWH (23-08-'04): Hibernate does this as well]!
In this post I’ll focus on how to implement a unidirectional one-to-one relationship using EJBs, JBoss and Xdoclet. In subsequent posts I’ll talk a bit more about one-to-many and many-to-many relationships. But we have to start as simple as possible with these complex matters
Let us first see how this is done generally, and then focus in on more details using a concrete example.