通过外键找主键
Session session = sessionFactory.getCurrentSession(); Class object = (Class) session.get(Class.class, 字段);
object.getId();
空指针异常需判断object 对象是否为空.