if you are hibernate4, you can use the HQL function 'type ()' to get the entity type
select type(e), e.name from Entity e
If you are hibernate3, session.iterate () returns an object as HibernateProxy with only an identifier, and you can get the name and identifier of an entity from it without initialization.
Iterator iterator = session.createQuery("from Entity e").iterate(); while(iterator.hasNext()) { HibernateProxy object = (HibernateProxy)iterator.next(); System.out.println(object.getHibernateLazyInitializer().getIdentifier()); System.out.println(object.getHibernateLazyInitializer().getEntityName()); }
source share