使用 Hibernate 在 java 中创建查询:无法解析 属性

Creating a query in java with Hibernate : could not resolve property

我正在尝试使用我在 class 中进行的查询来检索一些数据。 我在 Oracle SQL Developer 上尝试了这个查询,它工作正常,我从这个查询中得到了结果。 但是当我尝试通过 java 使用它时,它 returns 我出错了:

Could not getFlightInSandbox : could not resolve property: tacticalplanning_id of: com.atosorigin.airbus.evpt.model.Flight [select f.id from com.atosorigin.airbus.evpt.model.Flight f where f.isinsandbox = 'Y' and f.tacticalplanning_id in (select id from planning where domain like 'R%') and ((f.id in (select c.flight_id from changelog c where c.logactiontype_id in (select l.id from logactiontype l where l.key='APC7CREATE')))or (f.id in (select ca.flight_id from changelogarchive ca where ca.logactiontype_id in (select l.id from logactiontype l where l.key='APC7CREATE')))) and f.id not in (select flight_id from task where name='----APC7 UPD----')]

public List getFlightInSandbox() throws DAOException {
if (_log.isDebugEnabled()){
    _log.debug("getFlightsScheduling start ");
}
List results = new ArrayList();
try {
    Session session = HibernateUtil.currentSession();

    Date today = new Date();
    String todayString = DataFormating.formatDate(today, EvptConstants.FORMAT_DATE);
    LogCvaultImport.code(4500).info("todayString = "+todayString);

    Query request = session.createQuery(
            "select f.id "+
            "from Flight f "+
            "where f.isinsandbox = 'Y' "+
            "and to_char(f.begindate,'dd/MM/YYYY') >= :var1 "+
            "and f.tacticalplanning_id in (select id from planning where domain like 'R%') "+
            "and ((f.id in (select c.flight_id from changelog c where c.logactiontype_id in "+
                "(select l.id from logactiontype l where l.key='APC7CREATE')))"+
            "or (f.id in (select ca.flight_id from changelogarchive ca where ca.logactiontype_id in "+
                "(select l.id from logactiontype l where l.key='APC7CREATE')))) "+
            "and f.id not in (select flight_id from task where name='----APC7 UPD----')"
            );

    if (_log.isDebugEnabled()){
        _log.debug("getFlightInSandbox query = "+request.getQueryString());
    }
    request.setString("var1", todayString);
    results = request.list();
    if (_log.isDebugEnabled()){
        _log.debug("getFlightInSandbox todayString = "+todayString);
    }
} catch (Exception e) {
    _log.error("Could not getFlightInSandbox : " + e.getMessage());
} finally {
    if (_log.isDebugEnabled()){
        _log.debug("getFlightInSandbox end ");
    }
}
return results;
}

您正在使用 session.createQuery 来创建 HQL 查询,并且您想要执行 SQL 查询,因此请尝试 session.createSQLQuery