You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Som Som <2a...@gmail.com> on 2018/09/03 12:03:11 UTC
.net entity based configuration / datetime field error
Hello.
if I use Attributes Based Configuration I can put enitity into the cache
via key value api and than read rhis entity through the dbeaver(select *
from testentity)
*Code:*
namespace Example
{
public class TestEntity
{
[QuerySqlField]
public string ValueString { get; set; }
[QuerySqlField]
public DateTime ValueDateTime { get; set; }
}
class Program
{
static void Main(string[] args)
{
var ignite = Ignition.StartClient(newIgniteClientConfiguration {
Host = "127.0.0.1" });
var cache = ignite.GetOrCreateCache<int,TestEntity>(
new CacheClientConfiguration("TestEntity"
, new QueryEntity[] { newQueryEntity(typeof(TestEntity)) }) { SqlSchema =
"PUBLIC" });
cache.Put(1, new TestEntity { ValueString ="test",
ValueDateTime = DateTime.UtcNow });
ignite.Dispose();
}
}
}
But when I use QueryEntity Based Configuration (that is what I actually
need) a have an error running the same query in dbeaver
*Code:*
namespace Example
{
public class TestEntity
{
//[QuerySqlField]
public string ValueString { get; set; }
//[QuerySqlField]
public DateTime ValueDateTime { get; set; }
}
class Program
{
static void Main(string[] args)
{
var ignite = Ignition.StartClient(newIgniteClientConfiguration {
Host = "127.0.0.1" });
var queryEntity = new QueryEntity();
queryEntity.KeyTypeName =typeof(int).FullName;
queryEntity.KeyType = typeof(int);
queryEntity.ValueTypeName =typeof(TestEntity).FullName;
queryEntity.ValueType = typeof(TestEntity);
queryEntity.Fields = new QueryField[]
{ new QueryField("ValueString", typeof(string))
, new QueryField("ValueDateTime",typeof(DateTime))
};
var cache = ignite.GetOrCreateCache<int,TestEntity>(
newCacheClientConfiguration(
"TestEntity", queryEntity) { SqlSchema = "PUBLIC" });
cache.Put(1, new TestEntity { ValueString ="test",
ValueDateTime = DateTime.UtcNow });
ignite.Dispose();
}
}
}
*Result in dbeaver (select * from testentity):*
SQL Error [50000]: javax.cache.CacheException: Failed to run map query
remotely.Failed to execute map query on the node:
71b3514c-8d19-448d-9ae0-295fca1f4cbc, class
org.apache.ignite.IgniteCheckedException:Failed to execute SQL query.
General error: "class org.apache.ignite.binary.BinaryInvalidTypeException:
Unknown pair [platformId=0, typeId=-1854586790]"; SQL statement:
SELECT
__Z0.VALUESTRING __C0_0,
__Z0.VALUEDATETIME __C0_1
FROM PUBLIC.TESTENTITY __Z0 [50000-195]
How to use entity-based configuration correctly to get the correct result
via odbc with DateTime fields?
Re: .net entity based configuration / datetime field error
Posted by Som Som <2a...@gmail.com>.
thank you Pavel. It helped. I added
"IgniteConfiguration.BinaryConfiguration.Serializer
= new BinaryReflectiveSerializer { ForceTimestamp = true }" into config and
removed attribute and it works correctly.
вт, 4 сент. 2018 г., 9:35 Pavel Tupitsyn <pt...@apache.org>:
> Hi Som,
>
> The issue here is that Ignite writes DateTime in an internal format when
> [QuerySqlField] attribute is not present, to handle non-UTC values [1].
> This internal format is not SQL-compatible.
>
> There are multiple options to enforce TIMESTAMP format:
> * Implement IBinarizable
> * Implement IBinarySerializer
> * Set IgniteConfiguration.BinaryConfiguration.Serializer = new
> BinaryReflectiveSerializer { ForceTimestamp = true }
>
> The last one enforces TIMESTAMP format globally, and requires all DateTime
> values to be of DateTimeKind.Utc
> (which is actually a good practice for persisting date and time).
>
> Thanks,
> Pavel
>
> [1]
> https://apacheignite-net.readme.io/docs/sql-queries#section-java-type-name-mapping
>
> On Mon, Sep 3, 2018 at 7:10 PM Som Som <2a...@gmail.com> wrote:
>
>> I’m connecting to the server node via DBeaver (connection settings\ jdbc
>> url - jdbc:ignite:thin://xxx.xx.xx.xx/). I can query DateTime field if I
>> use Attributes Based Configuration and I get an error mentioned below in
>> case of using QueryEntity Based Configuration. How to configure a cache
>> with QueryEntity Based Configuration in .net in order to read DateTime via
>> jdbc.
>>
>>
>>
>> пн, 3 сент. 2018 г., 17:53 Igor Sapego <is...@apache.org>:
>>
>>> Which exactly ODBC driver are you talking about?
>>>
>>> Best Regards,
>>> Igor
>>>
>>>
>>> On Mon, Sep 3, 2018 at 4:48 PM wt <wa...@gmail.com> wrote:
>>>
>>>> not sure if it helps but the odbc driver doesnt play nice with date
>>>> fields
>>>> and deals with them in binary format
>>>>
>>>> class org.apache.ignite.binary.BinaryInvalidTypeException
>>>>
>>>> your error looks to be related - have you tried the jdbc driver as a
>>>> test?
>>>>
>>>>
>>>>
>>>> --
>>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>>
>>>
Re: .net entity based configuration / datetime field error
Posted by Pavel Tupitsyn <pt...@apache.org>.
Hi Som,
The issue here is that Ignite writes DateTime in an internal format when
[QuerySqlField] attribute is not present, to handle non-UTC values [1].
This internal format is not SQL-compatible.
There are multiple options to enforce TIMESTAMP format:
* Implement IBinarizable
* Implement IBinarySerializer
* Set IgniteConfiguration.BinaryConfiguration.Serializer = new
BinaryReflectiveSerializer { ForceTimestamp = true }
The last one enforces TIMESTAMP format globally, and requires all DateTime
values to be of DateTimeKind.Utc
(which is actually a good practice for persisting date and time).
Thanks,
Pavel
[1]
https://apacheignite-net.readme.io/docs/sql-queries#section-java-type-name-mapping
On Mon, Sep 3, 2018 at 7:10 PM Som Som <2a...@gmail.com> wrote:
> I’m connecting to the server node via DBeaver (connection settings\ jdbc
> url - jdbc:ignite:thin://xxx.xx.xx.xx/). I can query DateTime field if I
> use Attributes Based Configuration and I get an error mentioned below in
> case of using QueryEntity Based Configuration. How to configure a cache
> with QueryEntity Based Configuration in .net in order to read DateTime via
> jdbc.
>
>
>
> пн, 3 сент. 2018 г., 17:53 Igor Sapego <is...@apache.org>:
>
>> Which exactly ODBC driver are you talking about?
>>
>> Best Regards,
>> Igor
>>
>>
>> On Mon, Sep 3, 2018 at 4:48 PM wt <wa...@gmail.com> wrote:
>>
>>> not sure if it helps but the odbc driver doesnt play nice with date
>>> fields
>>> and deals with them in binary format
>>>
>>> class org.apache.ignite.binary.BinaryInvalidTypeException
>>>
>>> your error looks to be related - have you tried the jdbc driver as a
>>> test?
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>
>>
Re: .net entity based configuration / datetime field error
Posted by Som Som <2a...@gmail.com>.
I’m connecting to the server node via DBeaver (connection settings\ jdbc
url - jdbc:ignite:thin://xxx.xx.xx.xx/). I can query DateTime field if I
use Attributes Based Configuration and I get an error mentioned below in
case of using QueryEntity Based Configuration. How to configure a cache
with QueryEntity Based Configuration in .net in order to read DateTime via
jdbc.
пн, 3 сент. 2018 г., 17:53 Igor Sapego <is...@apache.org>:
> Which exactly ODBC driver are you talking about?
>
> Best Regards,
> Igor
>
>
> On Mon, Sep 3, 2018 at 4:48 PM wt <wa...@gmail.com> wrote:
>
>> not sure if it helps but the odbc driver doesnt play nice with date fields
>> and deals with them in binary format
>>
>> class org.apache.ignite.binary.BinaryInvalidTypeException
>>
>> your error looks to be related - have you tried the jdbc driver as a test?
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>
Re: .net entity based configuration / datetime field error
Posted by Igor Sapego <is...@apache.org>.
Which exactly ODBC driver are you talking about?
Best Regards,
Igor
On Mon, Sep 3, 2018 at 4:48 PM wt <wa...@gmail.com> wrote:
> not sure if it helps but the odbc driver doesnt play nice with date fields
> and deals with them in binary format
>
> class org.apache.ignite.binary.BinaryInvalidTypeException
>
> your error looks to be related - have you tried the jdbc driver as a test?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: .net entity based configuration / datetime field error
Posted by wt <wa...@gmail.com>.
not sure if it helps but the odbc driver doesnt play nice with date fields
and deals with them in binary format
class org.apache.ignite.binary.BinaryInvalidTypeException
your error looks to be related - have you tried the jdbc driver as a test?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/