2013-02-25 62 views
0

我有一個類的Hiberante HQL劑量不承認甲骨文替換功能

 class A { 
      String aField; 
      String bField; 
    } 

     class B { 
      A classAField 
    } 

我使用的限制,構建HQL

Restrictions.like(propertyName, obj); 

我封閉了的Oracle SQL功能可按替換propertyName刪除所有空格,所以propertyName是

replace(classAField.aField,' ') 

和我得到了以下錯誤

could not resolve property: replace(classAField of: B; nested exception is org.hibernate.QueryException: could not resolve property: replace(classAField of: B 

hiberante無法識別pl/sql函數。 我使用Oracle 10g中diaglect

<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 

is there a work around here? 

非常感謝

回答

0

對於這一點,你可能想Restrictions.sqlRestriction

讓它在你的特定情況下工作可能需要一些工作,但使用它你通常可以解決這樣的困難。

將它用於特定實體的特定字段不會強制您在任何地方使用它。它可以與其他限制混合使用。

+0

thanks.how做出的Hiberante使用替換,而不是使用sqlRestriction – sse 2013-02-25 04:04:56

+0

您可以在參數sqlRestriction使用它的功能。 – 2013-02-25 10:10:59

+0

問題是我不能爲所有實體使用sqlRestriction。我需要替換一個實體的特定屬性。所以我需要知道映射的列名和表別名。 – sse 2013-02-25 19:46:58

0

確定,標準查詢不認識的功能,但是使用了sqlRestriction