> 1) Declare my field as byte[] and serialize the supplied 
> object to it myself 
> (I'm pretty sure the byte[] cmp management works?)

It depends. I had problems with byte[] and InterBase JDBC driver. It is
caused by the same method: in case of byte array it does not try to wrap it
in the MarshalledObject, it uses stmt.setObject(...) instead. JDBC driver
detects that this is byte[] and stores data directly. However, while
deserializing, JBoss tries to deserialize the byte array into object and
fails. However, in case of Hypersonic SQL and InstantDB everything works
fine.

> 2) Declare the field as MyObject which just contains the real 
> object. This 
> should fool the code into unwrapping MyObject and then I can 
> extract the real 
> object from that.

That is exactly what I've tried. And it works. :)

Also you can use another approach: you can define two fields:
  Object realField;
  String dbField; // here you can use any type you like

then, in ejbCreate(...) (or any other modification method for the field) you
convert the realField into dbField. In ejb-jar.xml you specify that only
dbField is CMP field, and completely forget about the realField. Then, in
ejbLoad() you explicitely convert the dbField (which is already assigned by
JBoss) to realField. 

I'm currently using this approach to convert my byte[] PK into string
representation, which is better from database point of view for creating
indexes, etc.

Hope this helps.

Roman Rokytskyy

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to