Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB composite entities - why not use a DB view?  RSS feed

 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've been reading about "entity beans - composite entity".
That's when you have a single java class, whose storage is split between several DB tables.
E.g:
- Logically you want a single class "Book", with 3 attributes: (ISBN, price, author)
- But for some reason (that's a given), you need it stored in 2 DB tables (ISBN-price), (ISBN-author). So that you'll need a "Join" to get a whole book info.

My question: I've seen various recommendations for handling this (BMP, CMR, BMP that's composed of 2 CMP's...). But for some reason, I haven't seen a recommendation to just use a CMP over a database VIEW.
What am I missing ? Won't VIEW be a simple and easy solution ?
Or is there some performance problem with views ?

Thanks a lot.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


What am I missing ? Won't VIEW be a simple and easy solution ?
Or is there some performance problem with views ?

There is absolutely no problem with views, they are great actually. Simple, efficient, optimized, reliable; one cannot ask for more. However they have their own limitation though: they are very good tools for reading not updating the data. Now if your BMP entity bean maps to a view, how would you suggest to handle the database updates?
 
Balamaci Serban
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Views can be updated, i belive, the problem, would be what to do with the values in the tables outside the view. I guess if the view contained all the columns that would be ok.

With EJB u will have to fight with the DBA designer. To hell with his experience and logical design of databases. The entity bean suplies the data to the client so u have to impose your design on him. So what if it's not optimal and by that he loses 100MB of hard disk space. Get another harddisk.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!