Added comments on the latest code: https://github.com/hibernate/hibernate-orm/pull/566#issuecomment-22162265 Very complex!