E.g., looking at the Java EE 5 documentation for javax.persistence.EntityManager, why is the persist method declared as void persist(Object entity) but the merge method as <T> T merge(T entity)? Doesn’t it seem inconsistent or asymmetric that persist isn’t generified?
E.g., looking at the Java EE 5 documentation for javax.persistence.EntityManager, why is the persist
Share
The
persistmethod can take any kind of object (*) and returnsvoid. There is no variation.The
mergemethod returns an object of the same class as its parameter. In order to convey that, they need to use generics.(*) Of course, it needs to be an Entity, but that is not related to the class hierarchy (it is managed by annotations, not by marker interfaces).