ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yakov Zhdanov <yzhda...@apache.org>
Subject Re: SqlQuery Error
Date Thu, 24 Mar 2016 09:10:42 GMT
Can you please share the reproducible example or junit we can run locally
to reproduce?

--Yakov

2016-03-24 11:48 GMT+03:00 16616221@qq.com <16616221@qq.com>:

> Thanks for your reply. But my attributer id is String.
>
> The code is:
>
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to You under the Apache License, Version 2.0
>  * (the "License"); you may not use this file except in compliance with
>  * the License.  You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
>
> package org.apache.ignite;
>
> import java.sql.*;
> import java.util.*;
> import org.apache.ignite.cache.*;
> import org.apache.ignite.cache.store.jdbc.*;
> import org.apache.ignite.configuration.*;
>
> /**
>  * CacheConfig definition.
>  *
>  * Code generated by Apache Ignite Schema Import utility: 03/24/2016.
>  */
> public class CacheConfig {
>     /**
>      * Create JDBC type for testtable1.
>      *
>      * @param cacheName Cache name.
>      * @return Configured JDBC type.
>      */
>     private static JdbcType jdbcTypeTesttable1(String cacheName) {
>         JdbcType jdbcType = new JdbcType();
>
>         jdbcType.setCacheName(cacheName);
>         jdbcType.setDatabaseSchema("base");
>         jdbcType.setDatabaseTable("testtable1");
>         jdbcType.setKeyType("java.lang.String");
>         jdbcType.setValueType("org.apache.ignite.Testtable1");
>
>         // Key fields for testtable1.
>         Collection<JdbcTypeField> keys = new ArrayList<>();
>         keys.add(new JdbcTypeField(Types.VARCHAR, "id", String.class,
> "id"));
>         jdbcType.setKeyFields(keys.toArray(new
> JdbcTypeField[keys.size()]));
>
>         // Value fields for testtable1.
>         Collection<JdbcTypeField> vals = new ArrayList<>();
>         vals.add(new JdbcTypeField(Types.VARCHAR, "id", String.class,
> "id"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "attribute1",
> String.class, "attribute1"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "attribute2",
> String.class, "attribute2"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "attribute3",
> String.class, "attribute3"));
>         jdbcType.setValueFields(vals.toArray(new
> JdbcTypeField[vals.size()]));
>
>         return jdbcType;
>     }
>
>     /**
>      * Create SQL Query descriptor for testtable1.
>      *
>      * @return Configured query entity.
>      */
>     private static QueryEntity queryEntityTesttable1() {
>         QueryEntity qryEntity = new QueryEntity();
>
>         qryEntity.setKeyType("java.lang.String");
>         qryEntity.setValueType("org.apache.ignite.Testtable1");
>
>         // Query fields for testtable1.
>         LinkedHashMap<String, String> fields = new LinkedHashMap<>();
>
>         fields.put("id", "String");
>         fields.put("attribute1", "String");
>         fields.put("attribute2", "String");
>         fields.put("attribute3", "String");
>
>         qryEntity.setFields(fields);
>
>         // Indexes for testtable1.
>         Collection<QueryIndex> idxs = new ArrayList<>();
>
>         idxs.add(new QueryIndex("id", true, "PRIMARY"));
>
>         qryEntity.setIndexes(idxs);
>
>         return qryEntity;
>     }
>
>     /**
>      * Configure cache.
>      *
>      * @param cacheName Cache name.
>      * @param storeFactory Cache store factory.
>      * @return Cache configuration.
>      */
>     public static <K, V> CacheConfiguration<K, V> cache(String cacheName,
> CacheJdbcPojoStoreFactory<K, V> storeFactory) {
>         if (storeFactory == null)
>              throw new IllegalArgumentException("Cache store factory cannot
> be null.");
>
>         CacheConfiguration<K, V> ccfg = new
> CacheConfiguration<>(cacheName);
>
>         ccfg.setCacheStoreFactory(storeFactory);
>         ccfg.setReadThrough(true);
>         ccfg.setWriteThrough(true);
>
>         // Configure JDBC types.
>         Collection<JdbcType> jdbcTypes = new ArrayList<>();
>
>         jdbcTypes.add(jdbcTypeTesttable1(cacheName));
>
>         storeFactory.setTypes(jdbcTypes.toArray(new
> JdbcType[jdbcTypes.size()]));
>
>         // Configure query entities.
>         Collection<QueryEntity> qryEntities = new ArrayList<>();
>
>         qryEntities.add(queryEntityTesttable1());
>
>         ccfg.setQueryEntities(qryEntities);
>
>         return ccfg;
>     }
> }
>
>
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to You under the Apache License, Version 2.0
>  * (the "License"); you may not use this file except in compliance with
>  * the License.  You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
>
> package org.apache.ignite;
>
> import java.io.*;
>
> /**
>  * Testtable1 definition.
>  *
>  * Code generated by Apache Ignite Schema Import utility: 03/24/2016.
>  */
> public class Testtable1 implements Serializable {
>     /** */
>     private static final long serialVersionUID = 0L;
>
>     /** Value for id. */
>     private String id;
>
>     /** Value for attribute1. */
>     private String attribute1;
>
>     /** Value for attribute2. */
>     private String attribute2;
>
>     /** Value for attribute3. */
>     private String attribute3;
>
>     /**
>      * Empty constructor.
>      */
>     public Testtable1() {
>         // No-op.
>     }
>
>     /**
>      * Full constructor.
>      */
>     public Testtable1(
>         String id,
>         String attribute1,
>         String attribute2,
>         String attribute3
>     ) {
>         this.id = id;
>         this.attribute1 = attribute1;
>         this.attribute2 = attribute2;
>         this.attribute3 = attribute3;
>     }
>
>     /**
>      * Gets id.
>      *
>      * @return Value for id.
>      */
>     public String getId() {
>         return id;
>     }
>
>     /**
>      * Sets id.
>      *
>      * @param id New value for id.
>      */
>     public void setId(String id) {
>         this.id = id;
>     }
>
>     /**
>      * Gets attribute1.
>      *
>      * @return Value for attribute1.
>      */
>     public String getAttribute1() {
>         return attribute1;
>     }
>
>     /**
>      * Sets attribute1.
>      *
>      * @param attribute1 New value for attribute1.
>      */
>     public void setAttribute1(String attribute1) {
>         this.attribute1 = attribute1;
>     }
>
>     /**
>      * Gets attribute2.
>      *
>      * @return Value for attribute2.
>      */
>     public String getAttribute2() {
>         return attribute2;
>     }
>
>     /**
>      * Sets attribute2.
>      *
>      * @param attribute2 New value for attribute2.
>      */
>     public void setAttribute2(String attribute2) {
>         this.attribute2 = attribute2;
>     }
>
>     /**
>      * Gets attribute3.
>      *
>      * @return Value for attribute3.
>      */
>     public String getAttribute3() {
>         return attribute3;
>     }
>
>     /**
>      * Sets attribute3.
>      *
>      * @param attribute3 New value for attribute3.
>      */
>     public void setAttribute3(String attribute3) {
>         this.attribute3 = attribute3;
>     }
>
>     /** {@inheritDoc} */
>     @Override public boolean equals(Object o) {
>         if (this == o)
>             return true;
>
>         if (!(o instanceof Testtable1))
>             return false;
>
>         Testtable1 that = (Testtable1)o;
>
>         if (id != null ? !id.equals(that.id) : that.id != null)
>             return false;
>
>         if (attribute1 != null ? !attribute1.equals(that.attribute1) :
> that.attribute1 != null)
>             return false;
>
>         if (attribute2 != null ? !attribute2.equals(that.attribute2) :
> that.attribute2 != null)
>             return false;
>
>         if (attribute3 != null ? !attribute3.equals(that.attribute3) :
> that.attribute3 != null)
>             return false;
>
>         return true;
>     }
>
>     /** {@inheritDoc} */
>     @Override public int hashCode() {
>         int res = id != null ? id.hashCode() : 0;
>
>         res = 31 * res + (attribute1 != null ? attribute1.hashCode() : 0);
>
>         res = 31 * res + (attribute2 != null ? attribute2.hashCode() : 0);
>
>         res = 31 * res + (attribute3 != null ? attribute3.hashCode() : 0);
>
>         return res;
>     }
>
>     /** {@inheritDoc} */
>     @Override public String toString() {
>         return "Testtable1 [id=" + id +
>             ", attribute1=" + attribute1 +
>             ", attribute2=" + attribute2 +
>             ", attribute3=" + attribute3 +
>             "]";
>     }
> }
>
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/SqlQuery-Error-tp3658p3660.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Mime
View raw message