0

I am try to get the values from the results of a stored procedure using SimpleJdbcCall.

        SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(dataSource)
                .withProcedureName("getCryptData");
        SqlParameterSource in = new MapSqlParameterSource()
                .addValue("KCode", "")
                .addValue("tbl","comp")
                .addValue("CompId",tenant.toUpperCase());
        Map<String, Object> out = simpleJdbcCall.execute(in);

        String username = out.get;

        //Get DB Settings
        ArrayList result = (ArrayList) out.get("#result-set-1");
        Map source = (Map) result.get(0);

Although the below code works, I'm concerned about whether this is safe.

        //Get DB Settings
        ArrayList result = (ArrayList) out.get("#result-set-1");
        Map source = (Map) result.get(0);

I get this warning message.

Raw use of parameterized class

I want to know if this is ok for real-life production and any suggestions as to how I should change this will be appreciated.

ZhongYu
  • 53
  • 4

2 Answers2

1

While you can still continue to use your code in production, it should be avoided.

They usually require casts and they aren't type safe. They are also less expressive, and they don't provide self-documentation in the same way as parameterized types

When Generics was introduced in JDK 1.5, raw types were retained only to maintain backwards compatibility with older Java versions.

Thanks, Robin

0

It's still will run. But for clarity, you should avoid that. If you sure the type, then just cast it with that. After you cast it, you may still get the warning for unchecked casting. But you can suppress the warning by inserting @SuppressWarnings("unchecked"). For example:

@SuppressWarnings("unchecked")
List<Map<String, Object>> result = (List<Map<String, Object>>) out.get("#result-set-1");
Map<String, Object> source = result.get(0);
Ferry
  • 344
  • 3
  • 10