File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Views maps to business entities, good choice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Views maps to business entities, good choice?" Watch "Views maps to business entities, good choice?" New topic

Views maps to business entities, good choice?

Alfred Kemety
Ranch Hand

Joined: Aug 14, 2002
Posts: 279
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,

Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Views maps to business entities, good choice?
It's not a secret anymore!