Hello,
I wrote my own FieldConversion objects which implements FieldConversion interface.
It works well the first time, but as soon as I do an insert or an update the
conversion is not working again.
here is one of my FieldConversion object :
public class CustomerPrefix2IntegerFieldConversion implements
org.apache.ojb.broker.accesslayer.conversions.FieldConversion {
/** Creates a new instance of CustomerPrefix2IntegerFieldConversion */
public CustomerPrefix2IntegerFieldConversion() {
}
public Object javaToSql(Object obj) throws
org.apache.ojb.broker.accesslayer.conversions.ConversionException {
Integer id = null;
if (obj instanceof CustomerPrefix)
id = new Integer(((CustomerPrefix) obj).getId());
return id;
}
public Object sqlToJava(Object obj) throws
org.apache.ojb.broker.accesslayer.conversions.ConversionException {
CustomerPrefix cp = null;
if (obj instanceof Integer) {
int id = ((Integer) obj).intValue();
boolean found = false;
int i = 0;
Prefixes ps = Constant.hbkConfiguration.getPrefixes();
Prefix p = null;
while (!found && (i < ps.getPrefixCount())) {
p = ps.getPrefix(i);
if (Integer.parseInt(p.getId())==id)
found = true;
i++;
}
if (found) {
ArrayList al = new ArrayList();
cp = new CustomerPrefix();
cp.setId(id);
Value v = null;
Label l = null;
for (i = 0; i < p.getValueCount(); i++) {
v = p.getValue(i);
l = new Label();
l.setLanguageId(v.getLanguage().toString());
l.setContent(v.getContent());
al.add(l);
}
cp.setLabels((Label[]) al.toArray(new Label[al.size()]));
}
}
return cp;
}
}
where Constant.hbkConfiguration is a small Castor XML tree in static.
Does the FieldConversion objects are cached ? If yes can we disabled this in the ojb
properties ?
NB :
By the way, OJB is a great tool. (looks familiar to me because I work with TopLink).
It's a great saving of time !!!!!
Christophe
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]