Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to cast a Hashmap type to a Clob?

 
chaohua wang
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, folks,

I have a hibernate POJO object, which has a method

public void setResults(Clob results) {
this.results = results;
}


but i have variable pro, which is Map type and has some values.
I need to pass this Haspmap value to this mehtod,
like this,
dataobject.setResults((Clob)pro);

it can complie. but when i run it,

I got an exception,
17:24:12,332 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
17:24:12,332 ERROR [STDERR] Caused by: javax.transaction.TransactionRolledbackException: java.util.HashMap cannot be cast to java.sql.Clob; nested exception is:
java.lang.ClassCastException: java.util.HashMap cannot be cast to java.sql.Clob

How can i fix this issue? there is any way to cast Hashmap to a Clob.
Please help, Thank you!

Chwang
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Hashmaps and Clobs are completely different objects from different class hierarchies. So you have to create some adaptor yourself, going through all the Objects in the Map and convert is all into one Clob object.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic