You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Carlos Chávez <cc...@agssa.net> on 2005/04/06 19:24:36 UTC

set JdbcTypes for only one column


 Hi to all.

 is posible to set the jdbcTypes for only one column of the result of the
 query ?

 I know we can use the methode setJdbcTypes, but this need set the datatypes
 for all columns, i want to do this for only two columns, is this posible?.

 I try to do this:

 SELECT INVOICE_NUM, null AS USER1, null AS USER2 FROM INVOICE

 The problem is when the OJB try to convert the value for a
 java datatype, i think.

 the error are:

 Exception in thread "main" java.lang.NullPointerException
	at
org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
Source)
	at
org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
Source)
	at
org.apache.ojb.broker.accesslayer.ReportQueryRsIterator.getObjectFromResultSet(Unknown
Source)
	at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at
org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:829)
	at
org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:805)
	at
net.agssa.sga.forms.informes.InformesVentas.getListFacturasEmitidasInforme(InformesVentas.java:186)
	at ojb.ProductosFacturados.test(ProductosFacturados.java:20)
	at test.Test.main(Test.java:17)


 Cheers,

-- 
Carlos Chávez


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: set JdbcTypes for only one column

Posted by Carlos Chávez <cc...@agssa.net>.
  Hi Jakob.

Jakob Braeuchi Escribio :-)
> hi carlos,
>
> with the current versions of ojb you can only set the types for all
> columns.
>
> there are imo two ways to set the type of a specific column:
>
> 1.) pass the whole array of types but define a type to be ignored
> as the parameter is an array of int we cannot use null, so we need to
> define an intvalue that is ignored.
>
> 2.) provide an additional method which allows to set the type for a
> single column only.

  well, i think the both way are useful.

  for example if you have 10 field and you only need set the datatype
  for only one field, i'm think we do not need pass a array for only
  one field.

  the problem what i have is what i try to create a field that have a
  null value in the SQL(SELECT ..., null as field, for example), and the
  collection retrieve this value, maybe  is strange, but later a set the
  correct value of that field. i'm not always do this.

  Then i presume OBJ do not know wich datatype use because this value
  is not based in another field.

  Cheers.

  Carlos Chávez.
>
> wdyt
>
> jakob
>
> Carlos Chávez schrieb:
>>
>>  Hi to all.
>>
>>  is posible to set the jdbcTypes for only one column of the result of
>> the
>>  query ?
>>
>>  I know we can use the methode setJdbcTypes, but this need set the
>> datatypes
>>  for all columns, i want to do this for only two columns, is this
>> posible?.
>>
>>  I try to do this:
>>
>>  SELECT INVOICE_NUM, null AS USER1, null AS USER2 FROM INVOICE
>>
>>  The problem is when the OJB try to convert the value for a
>>  java datatype, i think.
>>
>>  the error are:
>>
>>  Exception in thread "main" java.lang.NullPointerException
>> 	at
>> org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
>> Source)
>> 	at
>> org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
>> Source)
>> 	at
>> org.apache.ojb.broker.accesslayer.ReportQueryRsIterator.getObjectFromResultSet(Unknown
>> Source)
>> 	at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at
>> org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:829)
>> 	at
>> org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:805)
>> 	at
>> net.agssa.sga.forms.informes.InformesVentas.getListFacturasEmitidasInforme(InformesVentas.java:186)
>> 	at ojb.ProductosFacturados.test(ProductosFacturados.java:20)
>> 	at test.Test.main(Test.java:17)
>>
>>
>>  Cheers,
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


-- 
Carlos Chávez

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: set JdbcTypes for only one column

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi carlos,

with the current versions of ojb you can only set the types for all 
columns.

there are imo two ways to set the type of a specific column:

1.) pass the whole array of types but define a type to be ignored
as the parameter is an array of int we cannot use null, so we need to 
define an intvalue that is ignored.

2.) provide an additional method which allows to set the type for a 
single column only.

wdyt

jakob

Carlos Chávez schrieb:
> 
>  Hi to all.
> 
>  is posible to set the jdbcTypes for only one column of the result of the
>  query ?
> 
>  I know we can use the methode setJdbcTypes, but this need set the datatypes
>  for all columns, i want to do this for only two columns, is this posible?.
> 
>  I try to do this:
> 
>  SELECT INVOICE_NUM, null AS USER1, null AS USER2 FROM INVOICE
> 
>  The problem is when the OJB try to convert the value for a
>  java datatype, i think.
> 
>  the error are:
> 
>  Exception in thread "main" java.lang.NullPointerException
> 	at
> org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
> Source)
> 	at
> org.apache.ojb.broker.metadata.JdbcTypesHelper.getObjectFromColumn(Unknown
> Source)
> 	at
> org.apache.ojb.broker.accesslayer.ReportQueryRsIterator.getObjectFromResultSet(Unknown
> Source)
> 	at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at
> org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:829)
> 	at
> org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:805)
> 	at
> net.agssa.sga.forms.informes.InformesVentas.getListFacturasEmitidasInforme(InformesVentas.java:186)
> 	at ojb.ProductosFacturados.test(ProductosFacturados.java:20)
> 	at test.Test.main(Test.java:17)
> 
> 
>  Cheers,
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org