From the monthly archives:

June 2010

Readonly property on spring form input

by Bruce on June 28, 2010

Be careful on Spring form:input tags. The readonly property on an HTML input element is readonly=”readonly” but on a Spring JSTL form:input tag the proper syntax is readonly=”true”…

<form:input readonly="true" ... >


by Bruce on June 20, 2010

A fantastic article about slowing down… “Don’t Be In A Hurry”


JDBC: Pass a List to a jdbc parameter

by Bruce on June 14, 2010

If you have a List and want to pass it to a JDBC query as a parameter, try this. In this example we have a list of widget names and we want in return a list of store Id’s. For the sake of this example we are not looking to associate which stores sell which widgets. We simply want to know of any store that sells any of the widgets.

public List<Map<String,Object>> getStoresByWidgets(List<String> widgetNameList) {
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("widgetNames", widgetNameList);
    String sql =
            "SELECT store_id \n" +
            "  FROM widget_store_vw wsv \n" +
            " WHERE store_status = 'Active' \n" +
            "   AND widget_name in (:widgetNames) ";
    return namedParameterJdbcTemplate.queryForList(sql, parameterMap);

{ 1 comment }

JPQL Syntax: joins are on the class member

by Bruce on June 14, 2010

In JPQL, if you want to join 2 or more tables explicitly, and not simply walk the relationships in your select or where clauses, you must list the class member of the second+ tables, not the the Object.

select c.keywords from Category c join c.keywords k where = ...
select c.keywords from Category c join Keywords k where = ...

I realize the above query could be written as ” from Keywords” but we needed to filter by Category Id and Keyword was mapped to Category via @ManyToMany. Is there still a better way? Please, teach me. Thanks.


Stack Trace Visibility via JNDI lookup

June 7, 2010 Java

We use a JNDI lookup to control whether a stack trace is visible. This allows us to have the stack trace visible in our development and test environments, but not in production. We have have maven deploy the correct according to your environment (which is outside the scope of this post). For example, in […]

Read the full article →