db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: Another issue
Date Thu, 29 Jan 2004 20:55:56 GMT
hi andy,

i just commited the patch to solve this problem.
the types of the columns can now be defined in the report-query:

Criteria crit = new Criteria();
Collection results = new Vector();
int types[] = new int[]{Types.DECIMAL, Types.VARCHAR, Types.BIGINT};

crit.addLike("firstname", "%o%");
ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
q.setColumns(new String[] { "id", "firstname", "count(*)" });
q.addGroupBy(new String[] { "id", "firstname" });
q.setJdbcTypes(types);

see QueryTest#testReportQueryWithJdbcTypes()

hth
jakob

Jakob Braeuchi wrote:
> hi andy,
> 
> i was digging a little deeper and imo we need to convert the ownerPk and 
> childPk to the types defined in the respective field-descriptors of the 
> pk-fields:
> 
> 
> ...
>         int ownerPkLen = getOwnerClassDescriptor().getPkFields().length;
>         int childPkLen = getItemClassDescriptor().getPkFields().length;
>         Object[] ownerPk = new Object[ownerPkLen];
>         Object[] childPk = new Object[childPkLen];
> 
> ...
>             Object[] mToN = (Object[])it.next();
>             System.arraycopy(mToN,0,ownerPk,0,ownerPkLen);
>             System.arraycopy(mToN,ownerPkLen,childPk,0,childPkLen);
> 
>           //conversion needed here!
>     
>             Identity ownerId = new Identity(null, ownerTopLevelClass, 
> ownerPk);
>             Identity childId = new Identity(null, childTopLevelClass, 
> childPk);
> ...
> 
> the field-descriptor know their jdbcTypes. the only thing we now need is 
> an easy way to convert between the types. the interface JdbcType already 
> provides a method called sequenceKeyConversion. what about adding an 
> additional conversion method ?
> 
> jakob
> 
> Jakob Braeuchi wrote:
> 
>> hi andy,
>>
>> this problem did not show up in previous builds because there was no 
>> prefetching of m:n-relationships ;)
>>
>> what about converting all numbers to Integer in 
>> MtoNCollectionPrefetcher#associateBatched ?
>>
>> jakob
>>
>> Andy Malakov wrote:
>>
>>> Hello Armin at all,
>>>
>>> I use Oracle 9i and OJB_BRANCH_1_0. What do you guys think about the 
>>> following problem (I will describe it step-by-step):
>>>
>>> ReportQueryRsIterator uses ResultSetMetaData to determine column 
>>> types (cannot not use class registry as others).
>>>
>>> Oracle maps INTEGER, INT, SMALLINT to NUMBER(38) datatype (JDBC: 
>>> java.sql.Types.NUMBER)
>>>
>>> ReportQueryRsIterator uses JdbcTypesHelper and maps 
>>> java.sql.Types.NUMBER into JdbcTypesHelper.T_Numeric data handler.
>>>
>>> JdbcTypesHelper.T_Numeric.readValueFromStatement() will produce 
>>> java.lang.BigDecimal.
>>>
>>> Problem is: java.lang.BigDecimal and java.lang.Integer have different 
>>> hash code algothims (1.4.2_02)- hash code values will be different 
>>> even for the same internal values.
>>>
>>> Side effect: MtoNCollectionPrefetcher.associateBatched(Collection 
>>> owners, Collection children, Collection mToNImplementors) fails 
>>> because it tries to match Identity that uses java.lang.BigDecimal PKs 
>>> with Identity that uses java.lang.Integer PKs.
>>>
>>> User-visible result: NullPointerException during complex object 
>>> retrieval in line: list.add(child);
>>>
>>> RC5 and previous build that I got about two weeks ago didn't had this 
>>> problem.
>>>
>>> Thanks a lot,
>>> Andy
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 

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


Mime
View raw message