ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ozgurnevres <ozgur.nev...@gmail.com>
Subject Re: How can I perform SqlFieldsQuery on DateTime field (binary cache)?
Date Mon, 27 Mar 2017 13:29:13 GMT


Hi, again
Thanks for the answer.

Now my PopulateCache method is like below (I didn't change any other thing
from my previous post):

        private static void PopulateCache(ICache<int, IBinaryObject> cache)
        {
            IBinary binary = cache.Ignite.GetBinary();

            // Populate persons.
            cache[1] = binary.GetBuilder(PersonType)
                .SetField(NameField, "James Wilson")
                .SetField(CompanyIdField, -1)
                .SetTimestampField("birthday", new DateTime(1950, 1,
1).ToUniversalTime())
                .Build();

            cache[2] = binary.GetBuilder(PersonType)
                .SetField(NameField, "Daniel Adams")
                .SetField(CompanyIdField, -1)
                .SetTimestampField("birthday", new DateTime(1960, 1,
1).ToUniversalTime())
                .Build();

            cache[3] = binary.GetBuilder(PersonType)
                .SetField(NameField, "Cristian Moss")
                .SetField(CompanyIdField, -1)
                .SetTimestampField("birthday", new DateTime(1970, 1,
1).ToUniversalTime())
                .Build();

            cache[4] = binary.GetBuilder(PersonType)
                .SetField(NameField, "Allison Mathis")
                .SetField(CompanyIdField, -2)
                .SetTimestampField("birthday", new DateTime(1980, 1,
1).ToUniversalTime())
                .Build();

            cache[5] = binary.GetBuilder(PersonType)
                .SetField(NameField, "Breana Robbin")
                .SetField(CompanyIdField, -2)
                .SetTimestampField("birthday", new DateTime(1990, 1,
1).ToUniversalTime())
                .Build();

            cache[6] = binary.GetBuilder(PersonType)
                .SetField(NameField, "Philip Horsley")
                .SetField(CompanyIdField, -2)
                .SetTimestampField("birthday", new DateTime(2000, 1,
1).ToUniversalTime())
                .Build();

            cache[7] = binary.GetBuilder(PersonType)
                .SetField(NameField, "James Peters")
                .SetField(CompanyIdField, -2)
                .SetTimestampField("birthday", new DateTime(2010, 1,
1).ToUniversalTime())
                .Build();

            // Populate companies.
            cache[-1] = binary.GetBuilder(CompanyType)
                .SetField(NameField, "Apache")
                .SetField(IdField, -1)
                .Build();

            cache[-2] = binary.GetBuilder(CompanyType)
                .SetField(NameField, "Microsoft")
                .SetField(IdField, -2)
                .Build();
        }

I am still getting an exception saying "Failed to parse query: select name,
birthdate from Person order by name" at the line below:

            var qry = cache.QueryFields(new SqlFieldsQuery("select name,
birthdate from Person order by name"));

ptupitsyn wrote
> Use SetTimestampField with DateTime instead of SetField, and use
> ToUniversalTime on values.
> 
> DateTime can be written in two formats, details:
> https://apacheignite-net.readme.io/docs/sql-queries#section-java-type-name-mapping





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-can-I-perform-SqlFieldsQuery-on-DateTime-field-binary-cache-tp11457p11473.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message