|
Few thoughts...
-
I am not sure what you mean exactly by "offer a generic version of get / load". Are you suggesting we change the signatures of get / load? Or are you suggesting adding additional types methods? Personally, I'd just not do anything with Session#get and Session#load specifically. These essentially are the untyped API. I'd vote to apply these to the IdentifierLoadAccess, NaturalIdLoadAccess and SimpleNaturalIdLoadAccess methods
-
At the moment nothing stops someone from using the same interface as proxy for more than one entity. This is the first semantic (non-API enforced) change proposed here.
-
At the moment the API allows users to quite happily (and really this is the only way the API works currently) perform a load/get by the entity class rather than the proxy class. This is the second semantic change proposed.
I am not really in favor of new typed variants of all the Class-accepting methods on Session (get and load are just some of the methods in question, and bear in mind that even just those "2" are already overloaded to accept locking options, or not). One option is to handle this in the org.hibernate.IdentifierLoadAccess and {[org.hibernate.NaturalIdLoadAccess}} approaches. Basically leave get, load, etc as-is and add type parameters to IdentifierLoadAccess and NaturalIdLoadAccess. Today we have:
-
public IdentifierLoadAccess byId(String entityName)
-
public IdentifierLoadAccess byId(Class entityClass)
-
public NaturalIdLoadAccess byNaturalId(String entityName)
-
public NaturalIdLoadAccess byNaturalId(Class entityClass)
-
public SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName)
-
public SimpleNaturalIdLoadAccess bySimpleNaturalId(Class entityClass)
We would expand this into:
-
public IdentifierLoadAccess byId(String entityName)
-
public <T> IdentifierLoadAccess<T> byId(Class<T> entityClass)
-
public <T> IdentifierLoadAccess<T> byId(Class entityClass, Class<T> proxy)
-
public NaturalIdLoadAccess byNaturalId(String entityName)
-
public <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
-
public <T> NaturalIdLoadAccess<T> byNaturalId(Class entityClass, Class<T> proxy)
-
public SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName)
-
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
-
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class entityClass, Class<T> proxy)
Not sure if we really need an un-typed variant for these. E.g.:
-
public IdentifierLoadAccess byIdUntyped(Class entityClass)
-
public NaturalIdLoadAccess byNaturalIdUntyped(Class entityClass)
-
public SimpleNaturalIdLoadAccess bySimpleNaturalIdUntyped(Class entityClass)
|