You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by "kcheng.mvp" <kc...@gmail.com> on 2017/12/02 08:17:35 UTC

Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

I run into this issue, cache.put/cache.get works well. 

here is my configuration.

<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="         http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd        
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <description>
    Main Spring file for ignite configuration.
  </description>
  <bean id="ignite.config.server"
class="org.apache.ignite.configuration.IgniteConfiguration"
scope="singleton">
    <property name="igniteInstanceName" value="ignitedc"/>
    <property name="peerClassLoadingEnabled" value="true"/>
    <property name="discoverySpi">
      <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
        <property name="ipFinder">
          <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
            <property name="addresses">
              <bean class="org.springframework.util.StringUtils"
factory-method="commaDelimitedListToStringArray">
                <constructor-arg type="java.lang.String"
value="172.18.118.143:47500..47509,172.18.118.141:47500..47509,172.18.118.142:47500..47509"/>
              </bean>
            </property>
          </bean>
        </property>
      </bean>
    </property>
    <property name="dataStorageConfiguration">
      <bean
class="org.apache.ignite.configuration.DataStorageConfiguration">
        <property name="pageSize" value="4096"/>
        <property name="defaultDataRegionConfiguration">
          <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
            <property name="persistenceEnabled" value="true"/>
          </bean>
        </property>
        <property name="dataRegionConfigurations">
          <list>
            <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
              <property name="name" value="UserSocial"/>
              <property name="initialSize" value="#{500L * 1024L * 1024L}"/>
              <property name="maxSize" value="#{1024L * 1024L * 1024L *
5L}"/>
              <property name="persistenceEnabled" value="true"/>
            </bean>
            <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
              <property name="name" value="UserInfo"/>
              <property name="initialSize" value="#{500L * 1024L * 1024L}"/>
              <property name="maxSize" value="#{1204L * 1024L * 1024L *
4L}"/>
              <property name="persistenceEnabled" value="true"/>
            </bean>
            <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
              <property name="name" value="UserAppInfo"/>
              <property name="initialSize" value="#{500L * 1024L * 1024}"/>
              <property name="maxSize" value="#{1204L * 1024L * 1024L *
3L}"/>
              <property name="persistenceEnabled" value="true"/>
            </bean>
            <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
              <property name="name" value="AppInfo"/>
              <property name="initialSize" value="#{500L * 1024L * 1024}"/>
              <property name="maxSize" value="#{1204L * 1024L * 1024L *
2L}"/>
              <property name="persistenceEnabled" value="true"/>
            </bean>
          </list>
        </property>
      </bean>
    </property>
    <property name="cacheConfiguration">
      <util:list xmlns:util="http://www.springframework.org/schema/util"
id="caches" value-type="org.apache.ignite.configuration.CacheConfiguration"
list-class="java.util.ArrayList">
        <bean parent="cache">
          <property name="name" value="UserSocial"/>
          <property name="dataRegionName" value="UserSocial"/>
        </bean>
        <bean parent="cache">
          <property name="name" value="UserInfo"/>
          <property name="dataRegionName" value="UserInfo"/>
        </bean>
        <bean parent="cache">
          <property name="name" value="UserAppInfo"/>
          <property name="dataRegionName" value="UserAppInfo"/>
        </bean>
        <bean parent="cache">
          <property name="name" value="AppInfo"/>
          <property name="dataRegionName" value="AppInfo"/>
        </bean>
      </util:list>
    </property>
  </bean>
  <bean id="cache"
class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
    <property name="cacheMode" value="PARTITIONED"/>
    <property name="backups" value="1"/>
  </bean>
</beans>

UserAppInfo.java

public class UserAppInfo implements Serializable{
    private static final long serialVersionUID = -6137971973241293268L;

    @QuerySqlField(index = true)
    private String appId;

    @QuerySqlField(index = true)
    private String uid;


    @QuerySqlField
    private String platform;


    @QuerySqlField
    private Date registerTime;

    @QuerySqlField
    private Date lastAuthTime;

    @QuerySqlField
    private Integer authCount;


    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getPlatform() {
        return platform;
    }

    public void setPlatform(String platform) {
        this.platform = platform;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }

    public Date getLastAuthTime() {
        return lastAuthTime;
    }

    public void setLastAuthTime(Date lastAuthTime) {
        this.lastAuthTime = lastAuthTime;
    }

    public Integer getAuthCount() {
        return authCount;
    }

    public void setAuthCount(Integer authCount) {
        this.authCount = authCount;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserAppInfo that = (UserAppInfo) o;

        if (appId != null ? !appId.equals(that.appId) : that.appId != null)
return false;
        return uid != null ? uid.equals(that.uid) : that.uid == null;
    }

    @Override
    public int hashCode() {
        int result = appId != null ? appId.hashCode() : 0;
        result = 31 * result + (uid != null ? uid.hashCode() : 0);
        return result;
    }

    public AffinityKey affinityKey(){
        return new AffinityKey(appId, uid);
    }
}

3: test code

 @Test
    public void happyFlow(){
        UserAppInfo userAppInfo = dynamicUserAppInfo();
        userAppInfoService.put(userAppInfo);
        UserAppInfo userAppInfo1 =
userAppInfoService.get(userAppInfo.getAppId(), userAppInfo.getUid());
        Assert.assertNotNull(userAppInfo1);
        Assert.assertEquals(userAppInfo1, userAppInfo); //works well
        SqlQuery sql = new SqlQuery(UserAppInfo.class, "appid =
?").setArgs(userAppInfo.getAppId());
       
userAppInfoService.getCache(PersistenceService.CacheName.USER_APP_INFO).query(sql);
// runs into the issue
    }



--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/

Re: Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

Posted by Valentin Kulichenko <va...@gmail.com>.
Not sure I understand the question. @QuerySqlField annotates a particular
field that can be in either key and value object. To specify which objects
are stored in cache and therefore which classes Ignite should scan for
these annotations, you should use setIndexedTypes.

Please refer to documentation I provided before and CacheQueryExample for
more details.

-Val

On Fri, Dec 8, 2017 at 8:16 AM, kcheng.mvp <kc...@gmail.com> wrote:

> thank you very much.
>
> as I had the settings as below, ignite should have enough information to
> figure out key and value type,right?
>
>  @QuerySqlField(index = true)
>     private String appId;
>
>     @QuerySqlField(index = true)
>     private String uid;
>
>
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>

Re: Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

Posted by "kcheng.mvp" <kc...@gmail.com>.
thank you very much.

as I had the settings as below, ignite should have enough information to
figure out key and value type,right?

 @QuerySqlField(index = true) 
    private String appId; 

    @QuerySqlField(index = true) 
    private String uid; 





--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/

Re: Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

Posted by Valentin Kulichenko <va...@gmail.com>.
You did not set CacheConfiguration#indexedTypes property. See documentation
for more details:
https://apacheignite.readme.io/docs/cache-queries#query-configuration-by-annotations

-Val

On Sat, Dec 2, 2017 at 12:24 AM, kcheng.mvp <kc...@gmail.com> wrote:

> by the way, here is my maven dependency.
>
> the unit test starts two server node local and a client node.
>
> <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-core</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>         <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-spring</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>         <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-indexing</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>
>
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>

Re: Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

Posted by Valentin Kulichenko <va...@gmail.com>.
You did not set CacheConfiguration#indexedTypes property. See documentation
for more details:
https://apacheignite.readme.io/docs/cache-queries#query-configuration-by-annotations

-Val

On Sat, Dec 2, 2017 at 12:24 AM, kcheng.mvp <kc...@gmail.com> wrote:

> by the way, here is my maven dependency.
>
> the unit test starts two server node local and a client node.
>
> <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-core</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>         <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-spring</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>         <dependency>
>             <groupId>org.apache.ignite</groupId>
>             <artifactId>ignite-indexing</artifactId>
>             <version>${ignite.version}</version>
>         </dependency>
>
>
>
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>

Re: Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to find SQL table for type: UserAppInfo

Posted by "kcheng.mvp" <kc...@gmail.com>.
by the way, here is my maven dependency.

the unit test starts two server node local and a client node.

<dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-core</artifactId>
            <version>${ignite.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-spring</artifactId>
            <version>${ignite.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-indexing</artifactId>
            <version>${ignite.version}</version>
        </dependency>






--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/