I use a "tinyint" in MySQL but you could use any INTEGER definition in your DDL 
depending on your RDBMS.

0=false
1=true

This is what my mapping looks like:

<field-descriptor id="5"
   name="active"
   column="ACTIVE"
  jdbc-type="INTEGER"
conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion" 
/>


Scott

> -----Original Message-----
> From: Brian McCallister [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 04, 2003 10:34 AM
> To: OJB Users List
> Subject: Mapping booleans
> 
> Whee, problem du jour.
> 
> What is the preferred technique for mapping booleans .9.8? Neither BIT
> nor BOOLEAN seem to work in the repository.xml, with errors as follows:
> 
> Mapping with BIT
> ---------
> [org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: SQLException
> during the execution of the insert (for a
> org.skife.registry.domain.Gift): ERROR:  column "suggestedgift" is of
> type bit but expression is of type boolean
>         You will need to rewrite or cast the expression
> 
> ERROR:  column "suggestedgift" is of type bit but expression is of type
> boolean
>         You will need to rewrite or cast the expression
> 
> [org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: SQLException
> during the execution of the insert (for a
> org.skife.registry.domain.Gift): ERROR:  column "suggestedgift" is of
> type bit but expression is of type boolean
>         You will need to rewrite or cast the expression
> 
> ERROR:  column "suggestedgift" is of type bit but expression is of type
> boolean
>         You will need to rewrite or cast the expression
> 
> --------
> Mapping with BOOLEAN
> --------
> Testcase: testCreateAndReloadUser took 6.222 sec
> Testcase: testAddRequestedGift took 0.174 sec
>         Caused an ERROR
> The type BOOLEAN for attribute suggestedgift can not be handled by OJB.
> Please specify only types as defined by java.sql.Types.
> java.lang.RuntimeException: The type BOOLEAN for attribute suggestedgift
> can not be handled by OJB. Please specify only types as defined by
> java.sql.Types.
> 
> I notice there is a converter for Integer to boolean, but the docs seem
> to say BIT is preferred.
> 
> Anyone?
> 
> -Brian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to