You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Kenan Dalley <ke...@gm.com> on 2016/12/16 17:24:25 UTC

Ignite with Cassandra questions / errors

Hi.  I have 2 questions regarding Ignite & Cassandra.

I'm using Ignite v1.8

I'm trying to get a very simple example working with read/write through to
c*, but I'm having some difficulty.

First, I'm trying to use the POJO strategy of configuration for both the key
& value persistence with the class fieldnames slightly different than the
column names, but defined in the @QuerySqlField(name="blah") annotation of
the POJO.  However, when it runs, I'm getting a "IgniteException: Failed to
prepare Cassandra CQL statement: insert into <keyspace>.
" and all of the column names are the lowercase names of the class field and
not what is defined in the annotation.  What's my problem? 
(configuration/class info to follow at the bottom)

Second, none of my "java.sql.Timestamp" fields are showing up in the insert
statement generated in the exception.  My c* columns are defined as
"timestamp" fields and what I've seen seems to indicate that those should be
"java.sql.Timestamp" datatypes, but it's not working.  How do I get my
Timestamp fields to be recognized?


===================
Ignite Exception:

[Mule] 2016-12-16 09:13:21,901  WARN 
-com.datastax.driver.core.ReplicationStrategy$NetworkTopologyStrategy.computeTokenToReplicaMap(ReplicationStategy.java:198) 
- Error while computing token map for keyspace dev_cirad with datacenter
dc1: could not achieve replication factor 3 (found 0 replicas only), check
your keyspace replication settings.
[09:13:22,324][SEVERE][main][CassandraCacheStore] Failed to execute
Cassandra CQL statement: insert into "mykeyspace"."HistoryResult"
("histname", "sessionid", "vin", "createdby", "modifiedby", "results")
values (?,?,?,?,?,?) using ttl 2592000;
class org.apache.ignite.IgniteException: Failed to execute Cassandra CQL
statement: insert into "mykeyspace"."HistoryResult" ("histname",
"sessionid", "vin", "createdby", "modifiedby", "results") values
(?,?,?,?,?,?) using ttl 2592000;
	at
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:163)

Caused by: class org.apache.ignite.IgniteException: Failed to prepare
Cassandra CQL statement: insert into "mykeyspace"."HistoryResult"
("histname", "sessionid", "vin", "createdby", "modifiedby", "results")
values (?,?,?,?,?,?) using ttl 2592000;
	at
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.prepareStatement(CassandraSessionImpl.java:615)
	at
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:133)
	... 20 more
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException:
Unknown identifier histname
	at
com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50)
	at
com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
	at
com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:98)
	at
org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.prepareStatement(CassandraSessionImpl.java:597)
	... 21 more

===================
cassandra-ignite.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    
    <import resource="classpath:cassandra-connection-settings.xml" />

    
    <bean id="HistoryResultCache_persistence_settings"
class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
        <constructor-arg type="org.springframework.core.io.Resource"
value="classpath:cassandra-persistence-settings.xml" />
    </bean>

    <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
        
        <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">
                            <list>
                                
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <property name="cacheConfiguration">
            <list>
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="HistoryResult" />
                    <property name="readThrough" value="true" />
                    <property name="writeThrough" value="true" />
                    
                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                            
                            <property name="dataSourceBean"
value="cassandraAdminDataSource" />
                            
                            <property name="persistenceSettingsBean"
value="HistoryResultCache_persistence_settings" />
                        </bean>
                    </property>
                </bean>
            </list>
        </property>
    </bean>
</beans>


===================
cassandra-connection-settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       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">

    <bean id="loadBalancingPolicy"
class="com.datastax.driver.core.policies.TokenAwarePolicy">
        <constructor-arg
type="com.datastax.driver.core.policies.LoadBalancingPolicy">
            <bean
class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
        </constructor-arg>
    </bean>

    <util:list id="contactPoints" value-type="java.lang.String">
	    <value>127.0.0.1</value>
    </util:list>

    <bean id="cassandraAdminDataSource"
class="org.apache.ignite.cache.store.cassandra.datasource.DataSource">
        <property name="contactPoints" ref="contactPoints"/>
        <property name="user" value="user"/>
        <property name="password" value="p@ssw0rd"/>
        <property name="readConsistency" value="ONE"/>
        <property name="writeConsistency" value="ONE"/>
        <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/>
    </bean>
</beans>

===================
cassandra-persistence-settings.xml

<persistence keyspace="mykeyspace" table="HistoryResult" ttl="2592000">
	<tableOptions>
		comment = 'Test table for Ignite/Cassandra connection'
		AND read_repair_chance = 0.2
	</tableOptions>

	<keyPersistence class="com.gm.model.HistoryResultKey" strategy="POJO" />

	<valuePersistence class="com.gm.model.HistoryResult" strategy="POJO" />
</persistence>

===================
HistoryResultKey.java

public class HistoryResultKey {
	@AffinityKeyMapped
	@QuerySqlField(index=true, groups={"historyResultPK"})
	private String vin;

	@QuerySqlField(index=true, groups={"historyResultPK"}, name="session_id")
	private String sessionId;
    
	@QuerySqlField(index=true, groups={"historyResultPK"}, name="hist_name")
	private String histName;

    public HistoryResultKey() {
        // No op.
    }

===================
HistoryResult.java

public class HistoryResult {
	@QuerySqlField
    private String vin;

	@QuerySqlField(name="session_id")
	private String sessionId;

	@QuerySqlField(name="session_time")
	private Timestamp sessionTime;

	@QuerySqlField(name="hist_name")
    private String histName;

	@QueryTextField
    private String results;

	@QuerySqlField(name="analysis_time")
    private Timestamp analysisTime;

	@QuerySqlField(name="created_dt")
    private Timestamp createdDate;

	@QuerySqlField(name="created_by")
    private String createdBy;

	@QuerySqlField(name="modified_dt")
    private Timestamp modifiedDate;

	@QuerySqlField(name="modified_by")
    private String modifiedBy;

    public HistoryResult() {
        // no op
    }

===================
TestCassandraPersistence.java

public class TestCassandraPersistence {
	/** Cache name. */
	private static final String CACHE_NAME =
HistoryResult.class.getSimpleName();

	/** Global HistoryResultKey to use across entire example. */
	private static HistoryResultKey key = new HistoryResultKey("vin1",
"sessionId1", "histName2");

	public static void main(String[] args) {
		try (Ignite ignite = Ignition.start("resources/cassandra-ignite.xml")) {
			System.out.println(StringUtils.EMPTY);
			System.out.println(">>> Cache store example started.");

			try (IgniteCache<HistoryResultKey, HistoryResult> cache = ignite
					.getOrCreateCache(new CacheConfiguration<HistoryResultKey,
HistoryResult>(CACHE_NAME))) {

				// Write to C*
				HistoryResult result = generateHistoryResultFromKey(key);
				System.out.println(String.format(">>> Putting to C*.  Key: [%s], Result:
[%s]", key, result));
				cache.put(key, result);

				// Clear cache
				System.out.println(StringUtils.EMPTY);
				System.out.println(">>> Clearing cache...");
				cache.clear(key);

				// Read from C*
				System.out.println(StringUtils.EMPTY);
				System.out.println(">>> Cache retrieve example started.");
				HistoryResult result2 = cache.get(key);
				System.out.println(String.format(">>> Read from C*.  Key: [%s], Result:
[%s]", key, result2));
			}
			System.out.println(StringUtils.EMPTY);
		}
	}

	private static HistoryResult generateHistoryResultFromKey(HistoryResultKey
key) {
		HistoryResult result = null;
		if (key != null) {
			result = new HistoryResult(key.getVin(), key.getSessionId(),
Timestamp.valueOf(LocalDateTime.now()),
					key.getHistName(), "results-" + LocalDateTime.now(),
Timestamp.valueOf(LocalDateTime.now()),
					Timestamp.valueOf(LocalDateTime.now()), "creator",
Timestamp.valueOf(LocalDateTime.now()),
					"updater");
		}
		return result;
	}
}



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Kenan Dalley <ke...@gm.com>.
Ah, now I understand.  

That worked.  Thanks!



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9913.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Igor Rudyak <ir...@gmail.com>.
Hi Kenan,

You missed the main point - getters or setters of your custom classes should
be annotated with *@QuerySqlField* instead of class private members. Here is
a slightly modified version of your custom classes which should work:

================================== 
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.cache.query.annotations.QuerySqlField;

public class HistoryResultKey {
    private String vin;

    private String sessionId;

    private String histName;

    public HistoryResultKey() {
        // No op.
    }

    public HistoryResultKey(final String vin, final String sessionId, final
String histName) {
        this.vin = vin;
        this.sessionId = sessionId;
        this.histName= histName;
    }

    @AffinityKeyMapped
    @QuerySqlField(index=true, groups={"historyResultPK"})
    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    @QuerySqlField(index=true, groups={"historyResultPK"},
name="session_id")
    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    @QuerySqlField(index=true, groups={"historyResultPK"}, name="hist_name")
    public String getHistName() {
        return histName;
    }

    public void setHistName(String histName) {
        this.histName= histName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;

        if (!(o instanceof HistoryResultKey))
            return false;

        HistoryResultKey that = (HistoryResultKey)o;

        if (vin != null ? !vin.equals(that.vin) : that.vin != null)
            return false;

        if (sessionId != null ? !sessionId.equals(that.sessionId) :
that.sessionId != null)
            return false;

        if (histName!= null ? !histName.equals(that.histName) :
that.histName!= null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int res = vin != null ? vin.hashCode() : 0;
        res = 31 * res + (sessionId != null ? sessionId.hashCode() : 0);
        res = 31 * res + (histName!= null ? histName.hashCode() : 0);
        return res;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("HistoryResultKey = [");
        sb.append("vin: ");
        sb.append(vin);
        sb.append(", sessionId: ");
        sb.append(sessionId);
        sb.append(", histName: ");
        sb.append(histName);
        sb.append("]");
        return sb.toString();
    }
}


================================== 
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.query.annotations.QueryTextField;

import java.util.Date;

public class HistoryResult {
    private String vin;

    private String sessionId;

    private Date sessionTime;

    private String histName;

    private String results;

    private Date analysisTime;

    private Date createdDate;

    private String createdBy;

    private Date modifiedDate;

    private String modifiedBy;

    public HistoryResult() {
        // no op
    }

    public HistoryResult(final String vin, final String sessionId, final
Date sessionTime,
                         final String histName, final String results, final
Date analysisTime,
                         final Date createdDate, final String createdBy,
final Date modifiedDate,
                         final String modifiedBy) {
        this.vin = vin;
        this.sessionId = sessionId;
        this.sessionTime = sessionTime;
        this.histName= histName;
        this.results = results;
        this.analysisTime = analysisTime;
        this.createdDate = createdDate;
        this.createdBy = createdBy;
        this.modifiedDate = modifiedDate;
        this.modifiedBy = modifiedBy;
    }

    @QuerySqlField
    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    @QuerySqlField(name="session_id")
    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    @QuerySqlField(name="session_time")
    public Date getSessionTime() {
        return sessionTime;
    }

    public void setSessionTime(Date sessionTime) {
        this.sessionTime = sessionTime;
    }

    @QuerySqlField(name="hist_name")
    public String getHistName() {
        return histName;
    }

    public void setHistName(String histName) {
        this.histName= histName;
    }

    @QueryTextField
    public String getResults() {
        return results;
    }

    public void setResults(String results) {
        this.results = results;
    }

    @QuerySqlField(name="analysis_time")
    public Date getAnalysisTime() {
        return analysisTime;
    }

    public void setAnalysisTime(Date analysisTime) {
        this.analysisTime = analysisTime;
    }

    @QuerySqlField(name="created_dt")
    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    @QuerySqlField(name="created_by")
    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @QuerySqlField(name="modified_dt")
    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    @QuerySqlField(name="modified_by")
    public String getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;

        if (o == null)
            return false;

        if (!(o instanceof HistoryResult))
            return false;

        HistoryResult that = (HistoryResult)o;

        if (vin != null ? !vin.equals(that.vin) : that.vin != null)
            return false;

        if (sessionId != null ? !sessionId.equals(that.sessionId) :
that.sessionId != null)
            return false;

        if (sessionTime != null ? !sessionTime.equals(that.sessionTime) :
that.sessionTime != null)
            return false;

        if (histName!= null ? !histName.equals(that.histName) :
that.histName!= null)
            return false;

        if (results != null ? !results.equals(that.results) : that.results
!= null)
            return false;

        if (analysisTime != null ? !analysisTime.equals(that.analysisTime) :
that.analysisTime != null)
            return false;

        if (createdDate != null ? !createdDate.equals(that.createdDate) :
that.createdDate != null)
            return false;

        if (createdBy != null ? !createdBy.equals(that.createdBy) :
that.createdBy != null)
            return false;

        if (modifiedDate != null ? !modifiedDate.equals(that.modifiedDate) :
that.modifiedDate != null)
            return false;

        if (modifiedBy != null ? !modifiedBy.equals(that.modifiedBy) :
that.modifiedBy != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int res = vin != null ? vin.hashCode() : 0;
        res = 31 * res + (sessionId != null ? sessionId.hashCode() : 0);
        res = 31 * res + (sessionTime != null ? sessionTime.hashCode() : 0);
        res = 31 * res + (histName!= null ? histName.hashCode() : 0);
        res = 31 * res + (results != null ? results.hashCode() : 0);
        res = 31 * res + (analysisTime != null ? analysisTime.hashCode() :
0);
        res = 31 * res + (createdDate != null ? createdDate.hashCode() : 0);
        res = 31 * res + (createdBy != null ? createdBy.hashCode() : 0);
        res = 31 * res + (modifiedDate != null ? modifiedDate.hashCode() :
0);
        res = 31 * res + (modifiedBy != null ? modifiedBy.hashCode() : 0);
        return res;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("HistoryResult = [");
        sb.append("vin: ");
        sb.append(vin);
        sb.append(", sessionId: ");
        sb.append(sessionId);
        sb.append(", sessionTime: ");
        sb.append(sessionTime);
        sb.append(", histName: ");
        sb.append(histName);
        sb.append(", results: ");
        sb.append(results);
        sb.append(", analysisTime: ");
        sb.append(analysisTime);
        sb.append(", createdDate: ");
        sb.append(createdDate);
        sb.append(", createdBy: ");
        sb.append(createdBy);
        sb.append(", modifiedDate: ");
        sb.append(modifiedDate);
        sb.append(", modifiedBy: ");
        sb.append(modifiedBy);
        sb.append("]");
        return sb.toString();
    }
}


For these two classes you Cassandra persistence descriptor could be as
simple as:

*<persistence keyspace="mykeyspace" table="HistoryResult" ttl="2592000">
    <tableOptions>
        comment = 'Test table for Ignite/Cassandra connection'
        AND read_repair_chance = 0.2
    </tableOptions>

    <keyPersistence class="com.gm.model.HistoryResultKey" strategy="POJO"/>
    <valuePersistence class="com.gm.model.HistoryResult" strategy="POJO"/>
</persistence>*



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9909.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Kenan Dalley <ke...@gm.com>.
That really wouldn't be the cause.  I didn't actually include the full bean
class implementations in the initial post in order to save space, but they
are actual fully-realized beans.

Here are their actual implementations.


==================================
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.cache.query.annotations.QuerySqlField;

public class HistoryResultKey {
	@AffinityKeyMapped
	@QuerySqlField(index=true, groups={"historyResultPK"})
	private String vin;

	@QuerySqlField(index=true, groups={"historyResultPK"}, name="session_id")
	private String sessionId;
    
	@QuerySqlField(index=true, groups={"historyResultPK"}, name="hist_name")
	private String histName;

    public HistoryResultKey() {
        // No op.
    }

    public HistoryResultKey(final String vin, final String sessionId, final
String histName) {
        this.vin = vin;
        this.sessionId = sessionId;
        this.histName= histName;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getHistName() {
        return histName;
    }

    public void setHistName(String histName) {
        this.histName= histName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;

        if (!(o instanceof HistoryResultKey))
            return false;

        HistoryResultKey that = (HistoryResultKey)o;

        if (vin != null ? !vin.equals(that.vin) : that.vin != null)
            return false;

        if (sessionId != null ? !sessionId.equals(that.sessionId) :
that.sessionId != null)
            return false;

        if (histName!= null ? !histName.equals(that.histName) :
that.histName!= null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int res = vin != null ? vin.hashCode() : 0;
        res = 31 * res + (sessionId != null ? sessionId.hashCode() : 0);
        res = 31 * res + (histName!= null ? histName.hashCode() : 0);
        return res;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("HistoryResultKey = [");
        sb.append("vin: ");
        sb.append(vin);
        sb.append(", sessionId: ");
        sb.append(sessionId);
        sb.append(", histName: ");
        sb.append(histName);
        sb.append("]");
        return sb.toString();
    }
}


===========================
import java.util.Date;

import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.query.annotations.QueryTextField;

public class HistoryResult {
	@QuerySqlField
    private String vin;

	@QuerySqlField(name="session_id")
	private String sessionId;

	@QuerySqlField(name="session_time")
	private Date sessionTime;

	@QuerySqlField(name="hist_name")
    private String histName;

	@QueryTextField
    private String results;

	@QuerySqlField(name="analysis_time")
    private Date analysisTime;

	@QuerySqlField(name="created_dt")
    private Date createdDate;

	@QuerySqlField(name="created_by")
    private String createdBy;

	@QuerySqlField(name="modified_dt")
    private Date modifiedDate;

	@QuerySqlField(name="modified_by")
    private String modifiedBy;

    public HistoryResult() {
        // no op
    }

    public HistoryResult(final String vin, final String sessionId, final
Date sessionTime,
                        final String histName, final String results, final
Date analysisTime,
                        final Date createdDate, final String createdBy,
final Date modifiedDate,
                        final String modifiedBy) {
    	this.vin = vin;
        this.sessionId = sessionId;
        this.sessionTime = sessionTime;
        this.histName= histName;
        this.results = results;
        this.analysisTime = analysisTime;
        this.createdDate = createdDate;
        this.createdBy = createdBy;
        this.modifiedDate = modifiedDate;
        this.modifiedBy = modifiedBy;
    }

	public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public Date getSessionTime() {
        return sessionTime;
    }

    public void setSessionTime(Date sessionTime) {
        this.sessionTime = sessionTime;
    }

    public String getHistName() {
        return histName;
    }

    public void setHistName(String histName) {
        this.histName= histName;
    }

    public String getResults() {
        return results;
    }

    public void setResults(String results) {
        this.results = results;
    }

    public Date getAnalysisTime() {
        return analysisTime;
    }

    public void setAnalysisTime(Date analysisTime) {
        this.analysisTime = analysisTime;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;

        if (o == null)
        	return false;

        if (!(o instanceof HistoryResult))
            return false;

        HistoryResult that = (HistoryResult)o;

        if (vin != null ? !vin.equals(that.vin) : that.vin != null)
            return false;

        if (sessionId != null ? !sessionId.equals(that.sessionId) :
that.sessionId != null)
            return false;

        if (sessionTime != null ? !sessionTime.equals(that.sessionTime) :
that.sessionTime != null)
            return false;

        if (histName!= null ? !histName.equals(that.histName) :
that.histName!= null)
            return false;

        if (results != null ? !results.equals(that.results) : that.results
!= null)
            return false;

        if (analysisTime != null ? !analysisTime.equals(that.analysisTime) :
that.analysisTime != null)
            return false;

        if (createdDate != null ? !createdDate.equals(that.createdDate) :
that.createdDate != null)
            return false;

        if (createdBy != null ? !createdBy.equals(that.createdBy) :
that.createdBy != null)
            return false;

        if (modifiedDate != null ? !modifiedDate.equals(that.modifiedDate) :
that.modifiedDate != null)
            return false;

        if (modifiedBy != null ? !modifiedBy.equals(that.modifiedBy) :
that.modifiedBy != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int res = vin != null ? vin.hashCode() : 0;
        res = 31 * res + (sessionId != null ? sessionId.hashCode() : 0);
        res = 31 * res + (sessionTime != null ? sessionTime.hashCode() : 0);
        res = 31 * res + (histName!= null ? histName.hashCode() : 0);
        res = 31 * res + (results != null ? results.hashCode() : 0);
        res = 31 * res + (analysisTime != null ? analysisTime.hashCode() :
0);
        res = 31 * res + (createdDate != null ? createdDate.hashCode() : 0);
        res = 31 * res + (createdBy != null ? createdBy.hashCode() : 0);
        res = 31 * res + (modifiedDate != null ? modifiedDate.hashCode() :
0);
        res = 31 * res + (modifiedBy != null ? modifiedBy.hashCode() : 0);
        return res;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("HistoryResult = [");
        sb.append("vin: ");
        sb.append(vin);
        sb.append(", sessionId: ");
        sb.append(sessionId);
        sb.append(", sessionTime: ");
        sb.append(sessionTime);
        sb.append(", histName: ");
        sb.append(histName);
        sb.append(", results: ");
        sb.append(results);
        sb.append(", analysisTime: ");
        sb.append(analysisTime);
        sb.append(", createdDate: ");
        sb.append(createdDate);
        sb.append(", createdBy: ");
        sb.append(createdBy);
        sb.append(", modifiedDate: ");
        sb.append(modifiedDate);
        sb.append(", modifiedBy: ");
        sb.append(modifiedBy);
        sb.append("]");
        return sb.toString();
    }
}





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9900.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Igor Rudyak <ir...@gmail.com>.
Ok, 

I took a look at the *HistoryResult* implementation once again and found the
reason. Your java class should follow  JavaBeans Conventions
<http://docstore.mik.ua/orelly/java-ent/jnut/ch06_02.htm>  . The most
important here is that you class should implement getters/setters methods
for READ/WRITE properties or getters for READ-ONLY properties.

In your case you just have a class with *private* members annotated by
*@QuerySqlField* - this will not work. You should implement getters/setters
methods for these *private* fields and then annotate getter or setter with
*@QuerySqlField*



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9887.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Kenan Dalley <ke...@gm.com>.
Ok, so I got my code working reading/inserting/updating from/to C*, but I had
to manually set up the persistence.xml as below and change my
java.sql.Timestamp types in the class to java.util.Date types.


<persistence keyspace="mykeyspace" table="HistoryResult" ttl="2592000">
	<tableOptions>
		comment = 'Test table for Ignite/Cassandra connection'
		AND read_repair_chance = 0.2
	</tableOptions>

	<keyPersistence class="com.gm.model.HistoryResultKey" strategy="POJO">
	    <partitionKey>
	        <field name="vin"/>
	    </partitionKey>
	    <clusterKey>
	        <field name="sessionId" column="session_id"/>
	        <field name="algorithmName" column="algorithm_name"/>
	    </clusterKey>
	</keyPersistence>
	<valuePersistence class="com.gm.model.HistoryResult" strategy="POJO"
serializer="org.apache.ignite.cache.store.cassandra.serializer.KryoSerializer">
        <field name="vin"/>
        <field name="sessionId" column="session_id"/>
	    <field name="sessionTime" column="session_time"/>
        <field name="algorithmName" column="algorithm_name"/>
        <field name="results"/>
	    <field name="analysisTime" column="analysis_time"/>
        <field name="createdDate" column="created_dt"/>
        <field name="createdBy" column="created_by"/>
        <field name="modifiedDate" column="modified_dt"/>
	    <field name="modifiedBy" column="modified_by"/>
	</valuePersistence>
</persistence>




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9877.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Kenan Dalley <ke...@gm.com>.
This is what I remember reading in the docs as well.  However, I just ran the
DDLGenerator using my Cassandra-persistence-settings.xml file and the
following is what it generated.  So, either I don't have something set up
correctly for Ignite to recognize the Annotations, or there's a problem in
the DDLGenerator such that the Annotations are being ignored by it.  I'm
perfectly willing to accept that I've done something wrong.  


-------------------------------------------------------------
DDL for keyspace/table from file:
resources/cassandra-persistence-settings.xml
-------------------------------------------------------------

create keyspace if not exists "dev_qlty"
with replication = {'class' : 'SimpleStrategy', 'replication_factor' : 3}
and durable_writes = true;

create table if not exists "dev_qlty"."HistoryResult"
(
 "algorithmname" text,
 "sessionid" text,
 "vin" text,
 "createdby" text,
 "modifiedby" text,
 "results" text,
 primary key (("algorithmname", "sessionid", "vin"))
) 
with comment = 'Test table for Ignite/Cassandra connection' AND
read_repair_chance = 0.2;





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9875.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite with Cassandra questions / errors

Posted by Igor Rudyak <ir...@gmail.com>.
Hi,

This is not actually 100% true - Cassandra integration supports
@QuerySqlField annotations to create tables and doing mapping between
object fields and table columns.

Kenan, have you tried Cassandra DDL generator
https://apacheignite-mix.readme.io/docs/ddl-generator for your persistence
descriptor? It will generate DDL for your table - such way you can check if
you missed something.

Igor



On Fri, Dec 16, 2016 at 11:01 AM, vkulichenko <valentin.kulichenko@gmail.com
> wrote:

> Hi,
>
> @QuerySqlField is annotation for Ignite SQL [1], it has nothing to do with
> Cassandra integration. To specify column name which differs from Java field
> name, you should use 'field' tags inside 'valuePersistence', like shown in
> the example [2].
>
> [1]
> https://apacheignite.readme.io/v1.8/docs/indexes#
> annotation-based-configuration
> [2] https://apacheignite-mix.readme.io/docs/examples#example-5
>
> -Val
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Ignite-with-Cassandra-questions-
> errors-tp9607p9608.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Ignite with Cassandra questions / errors

Posted by vkulichenko <va...@gmail.com>.
Hi,

@QuerySqlField is annotation for Ignite SQL [1], it has nothing to do with
Cassandra integration. To specify column name which differs from Java field
name, you should use 'field' tags inside 'valuePersistence', like shown in
the example [2].

[1]
https://apacheignite.readme.io/v1.8/docs/indexes#annotation-based-configuration
[2] https://apacheignite-mix.readme.io/docs/examples#example-5

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607p9608.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.