EhCache SearchableAttribute null值抛出NPE

时间:2015-08-19 21:09:33

标签: java ehcache

我对日期类型的searchableAttribute进行了以下映射。

<searchAttribute name="shipDate" type="java.util.Date" expression="value.getShipDate()"/>

我有以下代码可供搜索。

    Cache ocache = cm.getCache("orderCache");
    QueryManager qm = (QueryManagerBuilder.newQueryManagerBuilder()).addCache(ocache).build();
    String query = "select value from orderCache where (custId = '123' and shipDate > (date)'2013-11-22')";
    Results rs = qm.createQuery(query).end().execute();

上面的代码在下面的内部类中抛出NPE:

   /**
 * Get the appropriate @{link {@link AttributeType} enum for the given object value.
 *
 * @param name  the attribute name (only meaningful to message if exception thrown)
 * @param value the value to lookup the type for
 * @return the attribute type for this value
 * @throws SearchException if the given value is not valid for a search attribute
 */
public static AttributeType typeFor(String name, Object value) throws SearchException {
    if (name == null) {
        throw new NullPointerException("null name");
    }
    if (value == null) {
        throw new NullPointerException("null value");
    }

    AttributeType type = typeForOrNull(value);
    if (type != null) {
        return type;
    }

    throw new SearchException("Unsupported type for search attribute [" + name + "]: " + value.getClass().getName());
}

如何添加Nullable搜索属性???

0 个答案:

没有答案