• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity beans and database views  RSS feed

 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A co-worker asked me the following question (he's a database man, not a java-man) "The greatest limitation of entity beans is that they are limited to a 1:1-relationship with tables. How can I fool them into believing a view is a table?"

My problem here is that I have not used entity beans before entering this project, and thus have limited experience with them. It is true that in the project all entity beans correspond to a table in the db, but is it possible to map one entityEJB to a view instead?

My reply was, "you assume too much, I don't think entity beans have that limitation" and now I need to figure this out.

Using: CMP EntityEJBs, WebShpere Application Developer 5.1, Teradata db
 
Scott Selikoff
author
Bartender
Posts: 4081
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know for JDO and Hibernate there is no such limitation, you can map objects to tables in a 1:many and many:many relationship.

The previous EJB spec was pretty limited, but I believe 3.0 allows for more transparency. Someone else can answer this for sure.

You should also investigate inheritance (veritcal, horizontal and flat) as these are useful features you get in the OR world, that databases do not support as nicely.
[ December 15, 2005: Message edited by: Scott Selikoff ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to check the WebSphere documentation as mapping of an entity bean to multiple tables is vendor specific. I'm more familiar with WebLogic Server, where this is possible but each table must contain the same primary key columns. (The columns can have different names in different tables, but they must contain the same values.) In this case, when a new bean is created a row will be inserted in each table, and when a bean is removed a row is removed from each table. The rows in each table are related via their primary key values. The rows mapped to a particular entity bean will always have the same primary key value.
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot, guys. I should be able to get further with this.
[ December 15, 2005: Message edited by: �dne Brunborg ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!