The following works fine:

/**
 * @ojb.field jdbc-type="INTEGER"
 *
conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldCo
nversion"
 */
protected boolean deleted;

But, if you use:

@ojb.field jdbc-type="TINYINT"

Then, xdoclet does as it should:

    <field-descriptor
        name="deleted"
        column="deleted"
        jdbc-type="TINYINT"
conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldCo
nversion"
    >

And ojb dies (although i am kinda sympathetic as it is using Boolean2Int,
not Boolean2Tinyint!):

[PersistentField] ERROR: while set field:
[try to set 'object value' in 'target object'
target obj class: com.netcase.pol.bo.User
target field name: deleted
target field type: boolean
target field declared in: com.netcase.pol.bo.BaseBO
object value class: java.lang.Byte
object value: 0
]

...

Caused by: java.lang.IllegalArgumentException
        at
sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImp
l.java:68)
        at java.lang.reflect.Field.set(Field.java:656)
        at
org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNe
w.setValueFor(PersistentFieldDirectAccessImplNew.java:213)


Daniel.


> -----Original Message-----
> From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
> Sent: 07 September 2005 09:18
> To: OJB Users List
> Subject: Re: [junk] Re: Boolean2IntFieldConversion with TINYINT
>
>
> On 9/7/05, Daniel Perry <[EMAIL PROTECTED]> wrote:
> > What i mean, is that you cant do:
> >
> > <field-descriptor
> > name="deleted"
> > column="deleted"
> > jdbc-type="TINYINT"
> >
> conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2
> IntFieldCo
> > nversion"/>
> >
> > It would make sense to use tinyint for booleans.... as they
> only really need
> > 1bit!
> >
> > Problem is... i am using xdoclet to make the repository and
> torque to make
> > the database.  So, i have to use INTEGER in the xdoclet
> comment, so it ends
> > up as integer in the database.  I previously have put it as INTEGER then
> > used tinyint in mysql - but with xdoclet, everything is automated.
>
> What is the problem with this declaration ? Does XDoclet complain (it
> shouldn't) or does the JDBC driver complain or Torque ? Could you post
> the error and the generated SQL ?
>
> Btw, you could also try to use BIT as the datatype, it's meant to be
> used for boolean columns.
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to