You can't type cast the GenericValue.  You possibly can type cast one of the
objects it holds depending on the type.  Each GenericValue holds different
types if information depending on what it represents.  For example,

GenericValue existingOrderHeader = delegator.findByPrimaryKey("OrderHeader",
UtilMisc.toMap("orderId", orderId));
String customerId = externalOrderHeader.getString("customerPartyId");

if OrderHeader had a Double value in it, say "grandTotal", you could

double grandTotal =
externalOrderHeader.getDouble("grandTotal").doubleValue();


or

double grandTotal =
((Double)externalOrderHeader.get("grandTotal")).doubleValue();

Both of these will throw a ClassCastException if "grandTotal" is not a
double.

Everything in a GenericValue object is an object itself, i.e double is
wrapped in Double, etc.

Hope that helps

Skip

-----Original Message-----
From: vijay Si [mailto:[EMAIL PROTECTED]
Sent: Monday, September 24, 2007 11:12 PM
To: [email protected]
Subject: TypeCasting GenericValue object.


Hi,
I have been trying to type cast a generic value object to double and string,
but i get an error

"java.lang.ClassCastException: Cannot cast org.ofbiz.entity.GenericValue to
java.lang.xx"

Is there any particular way in ofbiz to work around this?

Regards

Reply via email to