Is it possible to combine these two? I use CMP entity beans in my app. In the entity bean's ejbCreate(), I also want to get data from another table, but I don't want to model the other table using another entity bean. So what's the best way to accomplish this. I don't think I can write SQL statements in ejbCreate() due to CMP. Thanks.
No problem. Conceptually, you define an resource ref for the entity bean in ejb-jar.xml and the corresponding JNDI xmls (depends on the app server). In your ejbCreate, call a DAO that can do any db manipulation. In the DAO, you do a JNDI lookup of the connection pool you defined that is also used by the CMP.
However, some setting differ between application server.
You write a DAO tier that make JDBC calls as well as CMP calls and can use the same connection, transaction context etc. via JNDI.