I would guess that you will need to write a conversion class for this. I am
using integer(1) for booleans, so I use the OJB conversion class
Boolean2IntFieldConversion
http://jakarta.apache.org/ojb/apidocs/org/apache/ojb/broker/accesslayer/conv
ersions/Boolean2IntFieldConversion.html

You might want to take a look at the source for this; it's really easy to
write your own conversion class. Then specify it in your class-descriptor as
a conversion entry like this

<class-descriptor class="com.package.Class" table="file_format">

<field-descriptor id="1"

name="oid"

column="oid"

jdbc-type="BIGINT"

primarykey="true"

autoincrement="true"/>

<field-descriptor id="2"

name="fixedLength"

column="fixed_length"

jdbc-type="INTEGER"

conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldCo
nversion"/>

</class-descriptor>



Dave Derry



----- Original Message -----
From: "Jan Zimmek" <[EMAIL PROTECTED]>


hi,

i have a class "TService" containing an attribute "enabled" of type boolean.

public class TService
{
    boolean enabled;
    public TService() {}
    public setEnabled(boolean enabled) {}
    public setEnabled(String enabled) {}
}


in my repository i defined the jdbc-type of this column to be "VARCHAR".

it works fine if i create a new instance of "TService" and call the broker
to store this object,
but when i try to fetch a collection of results:
Query q = new QueryByCriteria(TService.class, new Criteria());
Collection results = broker.getCollectionByQuery(q);

ojb throws a PersistenceBrokerException:

Unable to build object instance: TService

hmm ... when i change the datatype of class-attribute "enabled" to "String"
it works ... but boolean always fail.

Any suggestions would be greatly appreciated.


regards

jan zimmek




--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to