Ps.. this isn't a complaint about the new features, it's more just that I'm really bothered that people are going to see this as the "right" solution rather than as a "bridge" solution.
On the contrary, I see as very much the right solution, and a solution tied to a particular ORM tool such as Hibernate as a significantly "bridge" solution. AspectJ provides an elegant, general solution in this case, which is far less fragile than an API-dependent solution that adds an additional point to keep in synch between Spring and a variety of other frameworks.
As Seth pointed out, we have had such a solution for Hibernate for well over a year, with DependencyInjectionInterceptorFactoryBean. It has never been promoted to the core, rather than the sandbox, because it's not nearly as general a solution as the AspectJ solution. For example:
- As other posters have pointed out, the ORM tool doesn't always instantiate the object. E.g. imagine that the isUserNameUnique() method uses an injected service. I can write the following code and it will work:
Code:
User u = dao.findUserById(25); // Retrieved by Hibernate
if (!u.isUserNameUnique()) { ...
But if I do the following it will not work, as Hibernate doesn't yet know about the object:
Code:
User u = new User(uname, pwd, ...);
if (!u.isUserNameUnique()) { ...
- The Hibernate-specific solution is tied not only to Hibernate, but to a particular Hibernate version. E.g. we needed a Hib 3 version, because the Hib 2 one was broken by that incompatible migration. The AspectJ solution works with any ORM tool--imagine for example, switching between JPA providers, which you well might want to do in an evaluation scenario. The AspectJ solution also works in many scenarios other than O/R mapping. This means not only that there is a working mechanism regardless of the other tool or tools, but that users only need to learn one technique, and can then use it anywhere.
Rgds
Rod