Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-3756 - composite-id breaks UtcDateTime #1332

Closed
nhibernate-bot opened this issue Oct 13, 2017 · 3 comments
Closed

NH-3756 - composite-id breaks UtcDateTime #1332

nhibernate-bot opened this issue Oct 13, 2017 · 3 comments

Comments

@nhibernate-bot
Copy link
Collaborator

Malcolm created an issue — 13th February 2015, 19:53:03:

I discovered this while writing unit tests with in-memory sqlite.
I can reproduce this reliably with sqlite, I don't know if it happens with any other db.

If the nHibernate mapping contains a composite-id (even if there's only one field in it) any UtcDateTime field in the class will incorrectly map as if it's local time, ie. gains the timezone offset (though DateTime.Kind is set to UTC).


<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name="MyClass" table="my_table" dynamic-update="true">
      <composite-id>
        <key-property name="a_key" column="id" type="integer" />
      </composite-id>
     <property name="a*datetime" column="time*occurred" type="UtcDateTime" />
</class>
</hibernate-mapping>

If you turn the composite-id into an id (same structure), the DateTime maps correctly.
If you switch UtcDateTime to DateTime the date is the correctly store Utc date but marked as DateTimeKind.Unspecified.


Ricardo Peres added a comment — 13th February 2015, 23:51:03:

Can you submit a unit test?


Malcolm added a comment — 16th February 2015, 18:21:39:

unit test for failing case


Malcolm added a comment — 19th February 2015, 14:15:46:

Anything else I can provide for this issue?

@hazzik
Copy link
Member

hazzik commented Oct 17, 2017

@ngbrown @fredericDelaporte is it the same as #1362? Could you please check?

@fredericDelaporte
Copy link
Member

I will check its unit test (likely PR it).

@fredericDelaporte
Copy link
Member

Same issue, no need to have a composite Id for having it, solved with DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF; in connection string too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants