I’m using Hibernate 6, and I have some code I’ve been porting that uses Session.get with an entity name and identifier. We do a lot of reflection, and there’s some other background, so this may look a bit odd and explicitly passing the entity name may seem superfluous, but it’s necessary for us.
The entity name by itself doesn’t work, it seems to require the fully qualified name:
It’s an annotated POJO. That’s the entity annotation at the top of the code block, with the explicit name. It used to be hbm.xml mappings, and in that older version of Hibernate, we didn’t have issues with passing the entity name to get like this.
Which Hibernate version are you using? We actually have tests for these cases that ensure the collection is not initialized if the “owning side” is the many-to-one association.