Forums Register Login

How to cast a Hashmap type to a Clob?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 929 times.
Similar Threads
How to cast a Hashmap type to a Clob?
Create Immutable HashMap
DriverManager not getting connection.
HHow to pass a Map type to a Clob?
Clob to String (Using Hibernate)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:36:22.