ここに、hiberanteを使用して実行しているクエリがあります:
String sqlStr = "SELECT {User.*}," +
"{Address.*} from T_USER_DETAILS2 US,T_ADDRESS_DETAILS AD where US.ADDRESS_ID = AD.ADDRESS_ID" +
" AND US.USER_FIRSTNAME = :firstname";
SQLQuery sql = session.createSQLQuery(sqlStr).addEntity("User",User.class).addEntity("Address",Address.class);
sql.setParameter("firstname", firstname);
System.out.println("Query created, now executing the query in the database");
List<Object[]> list = sql.list();
hibernate によって生成されたクエリは次のとおりです。
Hibernate:
/* dynamic native SQL query */ SELECT
User.USER_ID as USER1_1_0_,
User.ADDRESS_ID as ADDRESS9_1_0_,
User.USER_AGE as USER2_1_0_,
User.USER_EMAIL as USER3_1_0_,
User.USER_FIRSTNAME as USER4_1_0_,
User.USER_LASTNAME as USER5_1_0_,
User.USER_PASSWORD as USER6_1_0_,
User.USER_COUNTRY_CODE as USER7_1_0_,
User.USER_PHONE as USER8_1_0_,
Address.ADDRESS_ID as ADDRESS1_0_1_,
Address.ADDRESS_LINE1 as ADDRESS2_0_1_,
Address.ADDRESS_LINE2 as ADDRESS3_0_1_,
Address.CITY as CITY0_1_,
Address.COUNTRY as COUNTRY0_1_,
Address.STATE as STATE0_1_
from
T_USER_DETAILS2 US,
T_ADDRESS_DETAILS AD
where
US.ADDRESS_ID = AD.ADDRESS_ID
AND US.USER_FIRSTNAME = ?
このエラーが発生しています:
キャッチ: org.hibernate.exception.SQLGrammarException: ORA-00923: FROM キーワードが期待される場所に見つかりません
このエラーは、select 句でコンマが欠落している場合に発生することを知っています。しかし、選択ですべてが完璧であることがわかります。誰でもこれについて私を助けることができますか?