File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes EJB  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB  " Watch "EJB  " New topic


ashok ks
Ranch Hand

Joined: Oct 31, 2003
Posts: 55
Is it possible to map Entity Bean with the Databse View instead of database Table ?
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
When working with database views I use Session Beans and JDBC. You cannot use CMP with views. You could try using BMP with views but you have to be carefull because if you change the view (i.e add some columns or remove some) the beans have to change also.
You could also try using DAO but I think using Session Beans with JDBC it's easy and reliable. I'm walking the path...
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Some CMP implementations allow mapping to database views. Check your particular appserver's documentation.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Vinod John
Ranch Hand

Joined: Jun 23, 2003
Posts: 162
Technically there should be no trouble mapping a Read only CMP EJB to a database view. But if you want read write CMP EJB then you may have some issues when executing DML statements (either database or the app server may restrict you). Personally "I" have mapped read-only CMP EJB to a database view in weblogic and oracle.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
I'll go ahead and second Lasse on this one. Support for views is entirely dependent on the Application Server. For example, I know that WebLogic definitely supports mapping CMP Beans to views.
As far as read-only vs. read-write... I see no problem using views for read-write operations. Of course, if you're view is sufficiently complex then you RDBMS might not allow updates.
I agree. Here's the link:
subject: EJB
It's not a secret anymore!