SeqHiLo and TableHiLo identity generators does not work with custom identity type
Description
Environment
Attachments
- 05 Aug 2013, 03:08 PM
Activity
Frantisek Jandos August 5, 2013 at 3:08 PM
You need Oracle database with ODP.NET to run this test case.
Frantisek Jandos August 5, 2013 at 3:07 PM
Hi Alexander,
I mean this note in NH documentation (which I have formerly overlooked): "sequence: ... The identifier returned by the database is converted to the property type using Convert.ChangeType. Any integral property type is thus supported."
But sequence generator also supports non (directly) integral type as shown in the enclosed test case, but not the SequenceHiLo generator as it does not know how to convert integral type to id class.
However the improvement will not be easy to implement as the design counts on calling the database with every new id and both hi/lo generators seems to me more like hack than straightforward solution.
Possibility to use id generator together with component as id would be the best solution.
Alex Zaytsev July 25, 2013 at 9:32 PM
Hi Frantisek Jandos,
Can you please explain what do you mean by "even not officially" is this some library/plugin?
Also a test case would be great.
Oskar Berggren July 16, 2013 at 4:09 PM
Haven't looked at the code myself, but if you think it makes sense, see if you can submit a patch or pull request, with unit tests, for this to happen.
Frantisek Jandos July 16, 2013 at 3:43 PM
I got your point, it is not, just integral types are supported. However it would be nice if both HiLo generators support custom types as sequence and table generators support it already (even not officially).
I am sorry to mark the issue as minor bug, I would like to change it to new feature.
When using custom identity type for strongly typed Ids instead of plain number as Id, SeqHiLo and TableHiLo identity generators does not work as they fail to convert the Id type returned by base class (SequenceGenerator/TableGenerator) to Int64 (long val = Convert.ToInt64(base.Generate(session, obj))
.