List:Commits« Previous MessageNext Message »
From:Bernd Ocklin Date:April 29 2010 1:17pm
Subject:bzr commit into mysql-5.1-telco-7.1 branch (bernhard.ocklin:3583)
View as plain text  
#At file:///Users/bocklin/Programming/71j/ based on revid:bernhard.ocklin@stripped

 3583 Bernd Ocklin	2010-04-29
      add clusterj files

    added:
      storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/LazyTest.java
      storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/model/LazyEmployee.java
      storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/LazyTest.java
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/HashOnlyLongIntStringPKTest.java
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryExplainTest.java
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/model/HashOnlyLongIntStringPK.java
      storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/HashOnlyLongIntStringPKTest.java
      storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/QueryExplainTest.java
=== added file 'storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/LazyTest.java'
--- a/storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/LazyTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/LazyTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,96 @@
+/*
+   Copyright (C) 2009 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package com.mysql.clusterj.jpatest;
+
+import javax.persistence.Query;
+
+import com.mysql.clusterj.jpatest.model.IdBase;
+import com.mysql.clusterj.jpatest.model.LazyEmployee;
+
+
+/** Test lazy loading support. Currently only remove and insert are tested.
+ * 
+ * Schema
+ * 
+drop table if exists t_basic;
+create table t_basic (
+  id int not null,
+  name varchar(32), // lazy with load fetch group (name, age)
+  age int,          // lazy with no load fetch group
+  magic int not null,
+  primary key(id)) 
+  engine=ndbcluster;
+create unique index idx_unique_hash_magic using hash on t_basic(magic);
+create index idx_btree_age on t_basic(age);
+
+*/
+@Ignore
+public class LazyTest extends AbstractJPABaseTest {
+
+    private int NUMBER_OF_INSTANCES = 4;
+
+    /** Subclasses must override this method to provide the model class for the test */
+    protected Class<? extends IdBase> getModelClass() {
+        return LazyEmployee.class;
+    }
+
+    public void test() {
+        removeAll(LazyEmployee.class);
+        em.getTransaction().begin();
+        for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
+            LazyEmployee e = createLazyEmployee(i);
+            em.persist(e);
+        }
+        em.getTransaction().commit();
+        em.clear();
+        em.getTransaction().begin();
+        Query query = em.createQuery("select e from LazyEmployee e where e.id = :id");
+        for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
+            query.setParameter("id", i);
+            LazyEmployee e = (LazyEmployee)query.getSingleResult();
+            int id = e.getId();
+            int magic = e.getMagic();
+            // name and age are lazily loaded
+            final int age;
+            final String name;
+            if (0 == i%2) {
+                // age and name are loaded separately because age has no load fetch group
+                age = e.getAge();
+                name = e.getName();
+            } else {
+                // age and name are loaded together because name's load fetch group includes age
+                name = e.getName();
+                age = e.getAge();
+            }
+            String result = new String("Lazy Employee " + id + " magic: " + magic + " age: " + age + " name: " + name);
+//            System.out.println(result);
+        }
+        em.getTransaction().commit();
+    }
+
+    private LazyEmployee createLazyEmployee(int i) {
+        LazyEmployee lazy = new LazyEmployee();
+        lazy.setId(i);
+        lazy.setAge(i);
+        lazy.setName("LazyEmployee " + i);
+        lazy.setMagic(i);
+        return lazy;
+    }
+
+}

=== added file 'storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/model/LazyEmployee.java'
--- a/storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/model/LazyEmployee.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-jpatest/src/main/java/com/mysql/clusterj/jpatest/model/LazyEmployee.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,81 @@
+/*
+   Copyright (C) 2010 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package com.mysql.clusterj.jpatest.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.FetchAttribute;
+import org.apache.openjpa.persistence.FetchGroup;
+import org.apache.openjpa.persistence.LoadFetchGroup;
+
+@Entity
+@Table(name="T_Basic")
+@FetchGroup(name="NameLoadFetchGroup",attributes={@FetchAttribute(name="age"), @FetchAttribute(name="name")})
+public class LazyEmployee implements IdBase, Serializable {
+
+    @Id
+    private int id;
+    @Basic(fetch=FetchType.LAZY)
+    @LoadFetchGroup("NameLoadFetchGroup")
+    private String name;
+    private int magic;
+    @Basic(fetch=FetchType.LAZY)
+    private Integer age;
+
+    public LazyEmployee() {}
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getMagic() {
+        return magic;
+    }
+
+    public void setMagic(int magic) {
+        this.magic = magic;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+}

=== added file 'storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/LazyTest.java'
--- a/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/LazyTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/LazyTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,23 @@
+/*
+   Copyright (C) 2009 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package com.mysql.clusterj.openjpatest;
+
+public class LazyTest extends com.mysql.clusterj.jpatest.LazyTest {
+
+}

=== added file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/HashOnlyLongIntStringPKTest.java'
--- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/HashOnlyLongIntStringPKTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/HashOnlyLongIntStringPKTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,183 @@
+/*
+   Copyright (C) 2009 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package testsuite.clusterj;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import testsuite.clusterj.model.HashOnlyLongIntStringPK;
+
+public class HashOnlyLongIntStringPKTest extends AbstractClusterJTest {
+
+    protected int PK_MODULUS = 2;
+    protected int NUMBER_OF_INSTANCES = PK_MODULUS * PK_MODULUS * PK_MODULUS;
+    protected long PRETTY_BIG_NUMBER = 1000000000000000L;
+    protected List<HashOnlyLongIntStringPK> instances = new ArrayList<HashOnlyLongIntStringPK>();
+
+    @Override
+    public void localSetUp() {
+        createSessionFactory();
+        session = sessionFactory.getSession();
+        tx = session.currentTransaction();
+        try {
+            tx.begin();
+            session.deletePersistentAll(HashOnlyLongIntStringPK.class);
+            tx.commit();
+        } catch (Throwable t) {
+            // ignore errors while deleting
+        }
+        createInstances();
+        addTearDownClasses(HashOnlyLongIntStringPK.class);
+    }
+
+    public void test() {
+        insert();
+        find();
+        update();
+        delete();
+        failOnError();
+    }
+
+    /** Insert all instances.
+     */
+    protected void insert() {
+        session.makePersistentAll(instances);
+    }
+
+    /** Find all instances.
+     */
+    protected void find() {
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            Object[] key = new Object[]{getPK1(i), getPK2(i), getPK3(i)};
+            HashOnlyLongIntStringPK result = session.find(HashOnlyLongIntStringPK.class, key);
+            verify(result, i, false);
+        }
+    }
+
+    /** Blind update every fourth instance.
+     */
+    protected void update() {
+        // update the instances
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            if (0 == i % 4) {
+                HashOnlyLongIntStringPK instance = createInstance(i);
+                instance.setStringvalue(getValue(NUMBER_OF_INSTANCES - i));
+                session.updatePersistent(instance);
+                verify(instance, i, true);
+            }
+        }
+        // verify the updated instances
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            if (0 == i % 4) {
+                Object[] key = new Object[]{getPK1(i), getPK2(i), getPK3(i)};
+                HashOnlyLongIntStringPK instance = session.find(HashOnlyLongIntStringPK.class, key);
+                verify(instance, i, true);
+            }
+        }
+    }
+
+    /** Blind delete every fifth instance.
+     */
+    protected void delete() {
+        // delete the instances
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            if (0 == i % 5) {
+                HashOnlyLongIntStringPK instance = createInstance(i);
+                session.deletePersistent(instance);
+            }
+        }
+        // verify they have been deleted
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            if (0 == i % 5) {
+                Object[] key = new Object[]{getPK1(i), getPK2(i), getPK3(i)};
+                HashOnlyLongIntStringPK instance = session.find(HashOnlyLongIntStringPK.class, key);
+                errorIfNotEqual("Failed to delete instance: " + i, null, instance);
+            }
+        }
+    }
+
+    /** The strategy for instances is for the "instance number" to create 
+     * the three keys, such that the value of the instance is:
+     * pk1 * PK_MODULUS^2 + pk2 * PK_MODULUS + pk3
+     * 
+     */
+    protected void createInstances() {
+        for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) {
+            HashOnlyLongIntStringPK instance = createInstance(i);
+//            System.out.println(toString(instance));
+            instances.add(instance);
+        }
+    }
+
+    /** Create an instance of HashOnlyLongIntStringPK.
+     * @param index the index to use to generate data
+     * @return the instance
+     */
+    protected HashOnlyLongIntStringPK createInstance(int index) {
+        HashOnlyLongIntStringPK instance = session.newInstance(HashOnlyLongIntStringPK.class);
+        instance.setLongpk(getPK1(index));
+        instance.setIntpk(getPK2(index));
+        instance.setStringpk(getPK3(index));
+        instance.setStringvalue(getValue(index));
+        return instance;
+    }
+
+    protected String toString(HashOnlyLongIntStringPK instance) {
+        StringBuffer result = new StringBuffer();
+        result.append("HashOnlyLongIntStringPK[");
+        result.append(instance.getLongpk());
+        result.append(",");
+        result.append(instance.getIntpk());
+        result.append(",\"");
+        result.append(instance.getStringpk());
+        result.append("\"]: ");
+        result.append(instance.getStringvalue());
+        result.append(".");
+        return result.toString();
+    }
+
+    protected long getPK1(int index) {
+        return PRETTY_BIG_NUMBER * ((index / PK_MODULUS / PK_MODULUS) % PK_MODULUS);
+    }
+
+    protected int getPK2(int index) {
+        return ((index / PK_MODULUS) % PK_MODULUS);
+    }
+
+    protected String getPK3(int index) {
+        return "" + (index % PK_MODULUS);
+    }
+
+    protected String getValue(int index) {
+        return "Value " + index;
+    }
+
+    protected void verify(HashOnlyLongIntStringPK instance, int index, boolean updated) {
+        errorIfNotEqual("PK1 failed", getPK1(index), instance.getLongpk());
+        errorIfNotEqual("PK2 failed", getPK2(index), instance.getIntpk());
+        errorIfNotEqual("PK3 failed", getPK3(index), instance.getStringpk());
+        if (updated) {
+            errorIfNotEqual("Value failed", getValue(NUMBER_OF_INSTANCES - index), instance.getStringvalue());
+        } else {
+            errorIfNotEqual("Value failed", getValue(index), instance.getStringvalue());
+
+        }
+    }
+
+}

=== added file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryExplainTest.java'
--- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryExplainTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryExplainTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,175 @@
+/*
+   Copyright (C) 2010 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package testsuite.clusterj;
+
+import java.util.Map;
+
+import com.mysql.clusterj.ClusterJUserException;
+import com.mysql.clusterj.Constants;
+import com.mysql.clusterj.Query;
+import com.mysql.clusterj.query.QueryBuilder;
+import com.mysql.clusterj.query.QueryDomainType;
+
+import testsuite.clusterj.AbstractQueryTest.QueryHolder;
+import testsuite.clusterj.model.AllPrimitives;
+
+/**
+drop table if exists allprimitives;
+create table allprimitives (
+ id int not null primary key,
+
+ int_not_null_hash int not null,
+ int_not_null_btree int not null,
+ int_not_null_both int not null,
+ int_not_null_none int not null,
+ int_null_hash int,
+ int_null_btree int,
+ int_null_both int,
+ int_null_none int,
+
+ byte_not_null_hash tinyint not null,
+ byte_not_null_btree tinyint not null,
+ byte_not_null_both tinyint not null,
+ byte_not_null_none tinyint not null,
+ byte_null_hash tinyint,
+ byte_null_btree tinyint,
+ byte_null_both tinyint,
+ byte_null_none tinyint,
+
+ short_not_null_hash smallint not null,
+ short_not_null_btree smallint not null,
+ short_not_null_both smallint not null,
+ short_not_null_none smallint not null,
+ short_null_hash smallint,
+ short_null_btree smallint,
+ short_null_both smallint,
+ short_null_none smallint,
+
+ long_not_null_hash bigint not null,
+ long_not_null_btree bigint not null,
+ long_not_null_both bigint not null,
+ long_not_null_none bigint not null,
+ long_null_hash bigint,
+ long_null_btree bigint,
+ long_null_both bigint,
+ long_null_none bigint *
+ */
+public class QueryExplainTest extends AbstractQueryTest {
+
+    @Override
+    public Class getInstanceType() {
+        return AllPrimitives.class;
+    }
+
+    @Override
+    void createInstances(int number) {
+        createAllPrimitivesInstances(10);
+    }
+
+    public void testExplainWithNoWhereClause() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with no where clause should have index none", "none", indexUsed);
+        assertEquals("Query explain with no where clause should have scan type TABLE_SCAN", "TABLE_SCAN", scanType);
+    }
+
+    public void testExplainBeforeBindingParameters() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("int_null_none").equal(dobj.param("equal")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        try {
+            query.explain();
+            fail("Explain before binding parameters should throw ClusterJUserException");
+        } catch (ClusterJUserException ex) {
+            // good catch; make sure message includes parameter name "equal"
+            assertTrue("Message should include parameter name \"equal\"", ex.getMessage().contains("equal"));
+        }
+    }
+
+    public void testExplainAfterBindingParametersNoIndexEqual() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("int_null_none").equal(dobj.param("equal")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        query.setParameter("equal", 1);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with no index should have index none", "none", indexUsed);
+        assertEquals("Query explain with no index should have scan type TABLE_SCAN", Query.SCAN_TYPE_TABLE_SCAN, scanType);
+    }
+
+    public void testExplainAfterBindingParametersUniqueEqual() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("int_not_null_hash").equal(dobj.param("equal")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        query.setParameter("equal", 1);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with PRIMARY key equal should have index int_not_null_hash", "idx_int_not_null_hash", indexUsed);
+        assertEquals("Query explain with PRIMARY key equal should have scan type UNIQUE_KEY", Query.SCAN_TYPE_UNIQUE_KEY, scanType);
+    }
+
+    public void testExplainAfterBindingParametersPrimaryEqual() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("id").equal(dobj.param("equal")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        query.setParameter("equal", 1);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with PRIMARY key equal should have index PRIMARY", "PRIMARY", indexUsed);
+        assertEquals("Query explain with PRIMARY key equal should have scan type PRIMARY_KEY", Query.SCAN_TYPE_PRIMARY_KEY, scanType);
+    }
+
+    public void testExplainAfterBindingParametersPrimaryLessThan() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("id").lessThan(dobj.param("lessThan")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        query.setParameter("lessThan", 1);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with PRIMARY key lessThan should have index PRIMARY", "PRIMARY", indexUsed);
+        assertEquals("Query explain with PRIMARY key lessThan should have scan type INDEX_SCAN", Query.SCAN_TYPE_INDEX_SCAN, scanType);
+    }
+
+    public void testExplainAfterBindingParametersPrimaryLessThanNull() {
+        QueryBuilder builder = session.getQueryBuilder();
+        QueryDomainType<AllPrimitives> dobj = builder.createQueryDefinition(AllPrimitives.class);
+        dobj.where(dobj.get("id").lessThan(dobj.param("lessThan")));
+        Query<AllPrimitives> query = session.createQuery(dobj);
+        query.setParameter("lessThan", null);
+        Map<String, Object> result = query.explain();
+        String indexUsed = result.get(Query.INDEX_USED).toString();
+        String scanType = result.get(Query.SCAN_TYPE).toString();
+        assertEquals("Query explain with PRIMARY key lessThan null should have index none", "none", indexUsed);
+        assertEquals("Query explain with PRIMARY key lessThan null should have scan type TABLE_SCAN", Query.SCAN_TYPE_TABLE_SCAN, scanType);
+    }
+
+}

=== added file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/model/HashOnlyLongIntStringPK.java'
--- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/model/HashOnlyLongIntStringPK.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/model/HashOnlyLongIntStringPK.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,56 @@
+/*
+   Copyright (C) 2009 Sun Microsystems Inc.
+   All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+package testsuite.clusterj.model;
+
+import com.mysql.clusterj.annotation.Column;
+import com.mysql.clusterj.annotation.PersistenceCapable;
+
+/** Schema
+ *
+drop table if exists longintstringpk;
+create table longintstringpk (
+ stringpk varchar(10) not null,
+ intpk int not null,
+ longpk bigint not null,
+ stringvalue varchar(10),
+        CONSTRAINT PK_longlongstringpk PRIMARY KEY (longpk, intpk, stringpk)
+
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY(intpk, longpk);
+
+ */
+@PersistenceCapable(table="hashonlylongintstringpk")
+public interface HashOnlyLongIntStringPK {
+
+    @Column(name="longpk")
+    long getLongpk();
+    void setLongpk(long value);
+
+    @Column(name="intpk")
+    int getIntpk();
+    void setIntpk(int value);
+
+    @Column(name="stringpk")
+    String getStringpk();
+    void setStringpk(String value);
+
+    @Column(name="stringvalue")
+    String getStringvalue();
+    void setStringvalue(String value);
+
+}

=== added file 'storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/HashOnlyLongIntStringPKTest.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/HashOnlyLongIntStringPKTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/HashOnlyLongIntStringPKTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,5 @@
+package testsuite.clusterj.tie;
+
+public class HashOnlyLongIntStringPKTest extends testsuite.clusterj.HashOnlyLongIntStringPKTest {
+
+}

=== added file 'storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/QueryExplainTest.java'
--- a/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/QueryExplainTest.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/QueryExplainTest.java	2010-04-29 13:17:34 +0000
@@ -0,0 +1,5 @@
+package testsuite.clusterj.tie;
+
+public class QueryExplainTest extends testsuite.clusterj.QueryExplainTest {
+
+}


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-telco-7.1 branch (bernhard.ocklin:3583)Bernd Ocklin29 Apr