There's no "official" way. Both are just objects instantiated with different data.
You could, although, check if the session
contains myobject1
/myobject2
(using the contians
method: http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/Session.html). This will work as long as you don't clear or change the persistence context, and will return true
for "current" entities and false
for the historical ones. But that's more of a work-around than a proper solution.