Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unchecked cast exception from object to String[] conversion

 
Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all
I get this 'unchecked cast exception from object to String[] conversion' so i have to suppress warnings for now.

outputMap is always map of <String,object>
What can i do to do type-safe casting as i do want to keep warnings suppressed.





Thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Casting is never type-safe: there's always the possibility of getting a ClassCastException at runtime when you do a cast. So, it's best to avoid having to cast as much as possible.

What framework are you using to do that database query? Does it always return a Map<String, Object> when you do a query? If yes, and you cannot change it, then you'll be forced to cast the Object value to something that you can use (such as a List<String[]> in your example).
 
Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using spring framework jdbc 3 for db access

Class SimpleJdbcCall has this method
Map<String,Object> execute() - Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.
I guess i would have to do the same i.e. suppress warnings .

Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic