开发者

Get BigDecimal value from Grails params

I am writing a reporting functionality for a Domain object in grails. There is field "balance" which is BigDecimal. I am having trouble writing the query. Appreciate any help.

View

<tr class="prop">
<td valign="top" class="name">
<label for="balance"><g:message code="sale.balance.label" default="Balance" /></label>
</td>
<td valign="top" class="value">
<g:textField name="balance" value="${params.balance}" />
</td>
</tr>

Controller

def c = Sale.createCriteria()
def saleList = c.list {
if(params.id)
    idEq(java.lang.Long.parseLong(params.id))
if(params.customerName)
    l开发者_如何转开发ike('customerName', params.customerName+"%")
if(params.customerPh)
    like('customerPh', params.customerPh+"%")
if(params.balance)
    ge('balance', java.math.BigDecimal(params.balance))
if(params.totalSale)
    ge('totalSale', params.totalSale)

Exception

groovy.lang.MissingPropertyException: No such property: java for class: grails.orm.HibernateCriteriaBuilder at colorthread.SaleController$_closure9_closure23.doCall(SaleController.groovy:289) at colorthread.SaleController$_closure9_closure23.doCall(SaleController.groovy)


You are missing the new keyword:

    ge('balance', new java.math.BigDecimal(params.balance))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜