ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardkblk <edward.kaganov...@blackrock.com>
Subject How to configure user data type for sql queries?
Date Fri, 01 Apr 2016 19:26:50 GMT
One of my cache fields is a custom type MyCustomDateType implements
Serializable, Comparable.  How can I map this type to be able to query via
sql?

I have tried the following, but was not able to get the sql result.  H2
Console shows the column data type for this field as 1111 (OTHER):

/
<bean class="org.apache.ignite.cache.QueryEntity">
	<property name="keyType" value="MyKey"/>
	<property name="valueType" value="MyObj"/>
			
	<property name="fields">
		<map>
		<entry key="id" value="java.lang.Integer"/>
		<entry key="type" value="MyCustomDataType"/>	                        
		</map>
	</property>
			
	<property name="indexes">
		<list>
		<bean class="org.apache.ignite.cache.QueryIndex">
			<constructor-arg> 
			        <map>
			         <entry key="id" value="true"/>
			         <entry key="type" value="false"/>
                                 ....

String sql = "id = ? and type  <= ? ";

SqlQuery<AffinityKey&lt;MyKey>, MyObj> q = new SqlQuery<>(MyObj.class,
sql);
q.setArgs(123, new MyCustomDataType("zzz");

List<Entry&lt;AffinityKey&lt;MyKey>, MyObj>> l = cache.query(q).getAll();
//<- no results
/



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-configure-user-data-type-for-sql-queries-tp3867.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message