db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maciej Regulski" <mregul...@go2.pl>
Subject serialization of an Object[] array and LIMIT option implementation
Date Tue, 16 Dec 2003 09:51:02 GMT
Hi,
I'm very beginer to OJB. I've got two questions.
Are you going to fix org.apache.ojb.broker.core.PersistenceBrokerImpl class
code to suport storing m:n relations implemented as an Object[] array?
I tried to patch it my self and finaly I got to this point when I had to
convert array of persistent object to Vector to avoid
java.lang.ClassCastException, but I don't think it is a good solution.

PersistenceBrokerImpl::storeCollections:

  [..]
                if (cds.isMtoNRelation())
                {
                    currentMtoNKeys = getMtoNImplementor(cds, obj);
                    // delete unused m:n implementors
                   //try-catch implementation added by Mathias for escape
from ClassCastException
                   try {
                        deleteMtoNImplementor(cds, obj, (Collection)col,
currentMtoNKeys);
                   } catch (ClassCastException cce) {
                        if (col.getClass().isArray()) {
                            System.out.println("::IF ENTERED");
                            deleteMtoNImplementor(cds, obj,
(Collection)pl.ojb.tools.Array2Vector.Convert((Object[])col),
currentMtoNKeys);
                        }
                   }
   [..]

And second question is connected with buiding SELECT statement. I know that
LIMIT option is specific for each database, but getting whole record set
from db server every time is a disaster. Espetially when you have thousands
of records in your sql tables. And again I had to interfere in OJB source
code:
org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement:getStatement

 [..]
        appendOrderByClause(orderByFields, orderByColumnNumbers, stmt);
 /**
  * PostgreSQL only LIMIT implementation
  * if the query has specified a start at index, and an end at index move to
the start at index.
  */
 int startAt = query.getStartAtIndex();
 int endAt = query.getEndAtIndex();
 if (startAt > 0) {
            stmt.append(" OFFSET "+String.valueOf(startAt));
 }
 if (endAt > 0) {
            int numberOfObjectsToFetch = endAt;
            if (startAt > 0) numberOfObjectsToFetch =
numberOfObjectsToFetch - startAt;
            stmt.append(" LIMIT "+String.valueOf(endAt));
 }
 return stmt.toString();

It works fine for me, but now I had to change db server to MySQL. :>


So is there any chance to have this issues solved with next version of
OJB???
Rgds
Mathias <mathias@irc.pl>


---------------------------------------------------------------------
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