1 回答

TA貢獻1805條經(jīng)驗 獲得超9個贊
如果它可以幫助其他人,那么解決方案是:
String QueryString = 'SELECT * FROM CUSTOMERS WHERE lastname = ?';
Query query = entityManager.createNativeQuery(QueryString);
Session session = entityManager.unwrap(JpaEntityManager.class).getActiveSession();
DatabaseQuery databaseQuery = query.unwrap(org.eclipse.persistence.jpa.JpaQuery.class).getDatabaseQuery();
DatabaseRecord recordWithValues= new DatabaseRecord();
query.setParameter(1, "toto");
recordWithValues.add(new DatabaseField(Integer.toString(1)), "toto");
databaseQuery.prepareCall(session, recordWithValues);
String sqlStringWithArgs = databaseQuery.getTranslatedSQLString(session, recordWithValues);
System.out.print(sqlStringWithArgs);
====SELECT * FROM CUSTOMERS WHERE lastname = 'toto'====
添加回答
舉報