List:Cluster« Previous MessageNext Message »
From:Serdyn du Toit Date:July 19 2013 1:09am
Subject:Re: CRUD in MySql general log
View as plain text  
Hi,

https://issues.apache.org/jira/browse/OPENJPA-2407

I had a more indepth look at this and fixed it.  Just to emphasize the
effect of this issue first - its impossible to run the same SELECT query
more than once as a NullPointerException occurs (using OpenJpa 2.2.2 and
MySql Cluster 7.3.2)

Someone from Oracle will need to drive the following change to
NdbOpenJPAStoreManager.java (modifying the solution if required of course)

Fix overview:
The NdbOpenJPAStoreManager#newQuery(String language) implementation is no
longer sufficient.

Fix details:
The modified NdbOpenJPAStoreManager can either be retrieved from the
issue's fix (https://issues.apache.org/jira/browse/OPENJPA-2407
) or just review the old newQuery(..) and its suggested replacement here:

package com.mysql.clusterj.openjpa;

public class NdbOpenJPAStoreManager extends JDBCStoreManager {

/**
 * https://issues.apache.org/jira/browse/OPENJPA-2407
 * Original broken implementation
 *
 * First method call for query:
 * - parameter language: javax.persistence.JPQL
 * - returns: NdbOpenJPAStoreQuery
 *
 * Successive method calls for identical query actually send in a different
 * language - contrary to perhaps older versions of OpenJpa
 * - parameter language: openjpa.prepared.SQL
 * - returns: broken NdbOpenJPAStoreQuery
 * As the language wasn't recognized by the implementation the
ExpressionParser
 * will be NULL resulting in a NPE.
 *
 * Analogously the JDBCStoreManager will have returned JDBCStoreQuery on the
 * first method call, and subsequently (contrary to perhaps older versions
of
 * OpenJpa) returned a PreparedSQLStoreQuery.
 *
 * The solution therefore is to just replace the whole method implementation
 * with that from JDBCStoreManager - just renaming variables as necessary
 * and replacing JDBCStoreQuery with NdbOpenJPAStoreQuery
(NdbOpenJPAStoreQuery
 * is a Ndb-specific subclass of JDBCStoreQuery with a minor customization)
 *
 * Rest of this class remains as previously.
 */
// @Override
// public StoreQuery newQuery(String language) {
//      ExpressionParser ep = QueryLanguages.parserForLanguage(language);
//      return new NdbOpenJPAStoreQuery(this, ep);
// }
/**
 * Copied and adapted from JDBCStoreManager as discussed above.
 */
    public StoreQuery newQuery(String language) {
        StoreQuery sq = newStoreQuery(language);
        if (sq == null || QueryLanguages.parserForLanguage(language) ==
null) {
            return sq;
        }

        QueryCache queryCache =
storeContext.getConfiguration().getDataCacheManagerInstance().getSystemQueryCache();
        if (queryCache == null) {
            return sq;
        }

        return new QueryCacheStoreQuery(sq, queryCache);
    }
    private StoreQuery newStoreQuery(String language) {
        ExpressionParser ep = QueryLanguages.parserForLanguage(language);
        if (ep != null) {
            return new NdbOpenJPAStoreQuery(this, ep);
        }
        if (QueryLanguages.LANG_SQL.equals(language)) {
            return new SQLStoreQuery(this);
        }
        if (QueryLanguages.LANG_PREPARED_SQL.equals(language)) {
            return new PreparedSQLStoreQuery(this);
        }
        return null;
    }

Thread
CRUD in MySql general logSerdyn du Toit14 Jul
  • Re: CRUD in MySql general logSerdyn du Toit14 Jul
    • Re: CRUD in MySql general logCraig L Russell14 Jul
      • Re: CRUD in MySql general logSerdyn du Toit15 Jul
        • Re: CRUD in MySql general logCraig L Russell15 Jul
          • Re: CRUD in MySql general logSerdyn du Toit15 Jul
            • Re: CRUD in MySql general logSerdyn du Toit19 Jul
              • Re: CRUD in MySql general logSerdyn du Toit22 Jul
              • Re: CRUD in MySql general logCraig L Russell20 Aug
  • Re: CRUD in MySql general logCraig L Russell14 Jul
    • Re: CRUD in MySql general logSerdyn du Toit14 Jul
      • Re: CRUD in MySql general logSerdyn du Toit15 Jul
        • Re: CRUD in MySql general logCraig L Russell15 Jul
          • Re: CRUD in MySql general logSerdyn du Toit16 Jul
            • Re: CRUD in MySql general logSerdyn du Toit16 Jul
              • Re: CRUD in MySql general logSerdyn du Toit22 Jul
                • Re: CRUD in MySql general logCraig L Russell23 Jul
                  • Re: CRUD in MySql general logSerdyn du Toit23 Jul
                    • Re: CRUD in MySql general logSerdyn du Toit23 Jul