通过方法调用类型为org.hibernate.Session

时间:2018-12-07 09:18:11

标签: java hibernate analysis

我正在静态分析使用Hibernate的应用程序。我的目的是确定由每个类操纵的模型类。让我给你举个例子。

public class myclass{
  public void saveOrUpdate(Item obj) throws Exception {
    try {
        startOperation();
        session.saveOrUpdate(obj);
        tx.commit();
    } catch (Exception e) {
        handleException(e);
        throw new Exception(e);
    } finally {
        close(session);
    }
  }
}

在此示例中, myclass 操作类 Item ,因为存在一个方法调用( session.saveOrUpdate(obj)),该方法具有参数为 Item 类型的对象。这是一个简单的例子。我的问题是,当静态类型为 Object 时,如何确定作为参数传递的对象的运行时类型。这是一个示例:

Public class myclass {
  public void saveOrUpdate(Object obj) throws Exception {
    try {
        startOperation();
        session.saveOrUpdate(obj);
        tx.commit();
    } catch (Exception e) {
        handleException(e);
        throw new Exception(e);
    } finally {
        close(session);
    }
  }
}

谢谢您的帮助。

0 个答案:

没有答案