Hi,

Thanks for reproducer.
I've make some changes and run test against 2.1, 2.2 and 2.3 version.
Test with affinity key fails on 2.1 and 2.2 versions and looks ok on 2.3
version.

Seems, there was a bug in 2.1 and it is already fixed in 2.3.

PFA repro.

On Thu, Oct 26, 2017 at 10:39 AM, iostream <sidds.mo...@gmail.com> wrote:

> One more thing to add - when I remove "affinityKey" from ID, I am able to
> query successfully. The error occurs when I set "ID" as my affinityKey. Is
> it a known bug?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov
package userlist;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;

/** */
public class AFTest extends GridCommonAbstractTest {

    /** {@inheritDoc} */
    @Override protected void beforeTest() throws Exception {
        super.beforeTest();

        startGrid(0);
    }

    /** {@inheritDoc} */
    @Override protected void afterTest() throws Exception {
        super.afterTest();

        stopAllGrids();
    }

    /** */
    public void testNoAffinityKey() throws Exception {
        checkDDLQuery("CREATE TABLE Person (id BIGINT,name VARCHAR,PRIMARY KEY (id))" +
            "WITH \"backups=1\"");
    }

    /** */
    public void testWithAffinityKey() throws Exception {
        checkDDLQuery("CREATE TABLE Person (id BIGINT,name VARCHAR,PRIMARY KEY (id))" +
            "WITH \"backups=1,affinityKey=id\"");
    }

    /** */
    public void checkDDLQuery(String sql) throws Exception {
        ResultSet rs = null;

        Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
        try(Connection conn = DriverManager
            .getConnection("jdbc:ignite:thin://127.0.0.1:10800/")) {

            // create table
            try (PreparedStatement stmt = conn.prepareStatement(sql)) {
                stmt.executeUpdate();
            }

            // create table
            try (PreparedStatement stmt = conn.prepareStatement(
                "INSERT INTO Person (id,name) VALUES (?,?)")) {
                stmt.setLong(1,1L);
                stmt.setString(2,"John");
                stmt.executeUpdate();
            }

            // Try to query
            try (PreparedStatement stmt2 = conn.prepareStatement("select * from Person where id = ?")) {
                stmt2.setObject(1, 1L);
                rs = stmt2.executeQuery();

                rs.next();

                System.out.println(rs.getLong(1));
                System.out.println(rs.getString(2));
            }
        }
    }
}

Reply via email to