This kind of problems require some analysis but here is an oversimplified answer:
Look at your EJB CMP layer and think about the things it's doing. In most cases, CMP EJBs,
1. Capture the domain model as EJBs
2. Define mappings to map EJBs to the database tables
3. Container takes care of executing transactions etc.
If you want to move away from CMP EJBs you will have to think of ways to do these things in your code. Here is what I would propose:
1. Create a layer of domain layer POJOs. If you had say AccountEJB, you will now have AccountVO. Note that you can still have primary key class etc. like you did before
2. Create a way to map VOs to database tables. This can be done by either creating a layer of DAOs and writing
JDBC code in them OR by using a framework such as Toplink or Hibernate
3. Create a layer of stateless session beans (you probably have this already), which would either access DAO or invoke Hibernate to perform CRUD operations. Define transactions etc. on sessions beans
To specifically, answer your question, yes, you can use Java code - DAO - database as long as you take care of transactions etc.
Hope this helps, let me know if you have more questions...
Chintan