Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Views maps to business entities, good choice?

Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a conversation about mapping data to objects, I was presenting the problem of displaying data saved in a database that I have. Once we start talking about retrieving data from a complex database schema, logical basic entities can't really hold the data in a good format.

To explain myself, I'll take the most common example.
customer, order, order_details, product, vendor.
Customer, Order, Product, Vendor.

Customer has a collection of Orders, Order has a collection of Products, Product has a Vendor Object and a Country Object (or just a string . Very simple basic and nice.

Now I want to display a list of product names and their vendors names for a certain customer. In the Database, it's simple, I'll create a view that inner joins customer to order, order to order_details, order_details to product, product to vendor, SELECT the names and uniqe identifiers and life is easy.

Now in the data tier I connect (JDBC) get a JdbcRowSetXImpl, and........ hmmmm now I don't want to send to the interface a typless result set to display, I want to put the data into a business entity that I can simply bind to a JSF data table. None of the business entities is suitable to create an object collection from and pass it to the interface...

One suggestion was to create a business entity to every view that I have in the DB, it's a big investement in the begining to make such a factory but then once done, adding to it is not going to be difficult. Also there are some software that would generate the entities automatically.

Is this a good approach? What's a better approach. Note that I want to be able to simply and directly bind the collection of entities to the data table directly to display it.

Thanks in advance for your input,
    Bookmark Topic Watch Topic
  • New Topic