Retrieve primary key from entity class from sessionfactory in hibernate
问题 I am creating one SessionFactory using hibernate and I need the primary key of all the tables associated with the entity classes generated from the SessionFactory. Is there any way to achieve this? I have created SessionFactory and from the gathered the ClassMetaData. But unable to retrieve the primary key from the ClassMetaData. 回答1: I don't know which Hibernate version you have. This works for version 4.2.x: Configuration con = // get the org.hibernate.cfg.Configuration for(Iterator