Panasonic Youth

Neward's paper on the OR mismatch and LINQ

Ted Neward recently posted an extensive paper comparing various OR solutions from over the years, including JDBC, SQLJ, and ActiveRecord. Of course, the paper finished up by showing .NET’s upcoming solution with LINQ and how it “hopes to take a large step forward in minimizing the object-relational mismatch.” It allows you to code something like this (this retrieves Order, OrderDetails and Product in the Northwind db in one request):

[csharp]var custs = ( from c in db.Customers where c.City == “London” select c ) .Including(c => c.Orders .Including(o => o.OrderDetails .Including(od => od.Product)));

foreach (var cust in custs) { foreach (var ord in cust.Orders) { foreach (var orderDetail in ord.OrderDetails) { Console.WriteLine(“CustomerID {0} has an OrderID {1} “ + “with ProductID {2} that has name {3}.”, cust.CustomerID, ord.OrderID, orderDetail.ProductID, orderDetail.Product.ProductName); } } }[/csharp]

Even with a higher level of abstraction such as Spring’s JdbcTemplate, I can imagine it would be quite a bit nastier. I’d love to see something like this come to Java, either in the next JDBC but more likely via Hibernate or Spring. Go read the paper and let Ted know what you think.