unit testing - NHibernate ISession.Replicate with SQLite and native id generation -
we mapping primary key of object this:
id(x => x.id, "id").generatedby.native("sequencename");
we have business logic depending on ids exist (legacy, not changed). new objects should generated ids oracle sequence, there rows known ids.
we're using sqlite unit testing , need persist new objects in-memory database these known ids. not work of following methods:
session.replicate(objectwithknownid, <any replication mode>); session.merge(objectwithknownid)
according nhibernate documentation, replicate
method seems i'm looking for.
persist reachable transient objects, reusing current identifier values.
when using sqlite, however, generated ids. can think of way of solving this?
i typically run database tests against database i'm running app against - sqlite can quick tests missing many of features you'll find in full blown dbms. may able use method 1 discussed here tweak mappings @ runtime if mapping issue.
you preload sqlite database entities need, , copy in reuse every time run test. route take this, can't offer technical details on how it.
to honest sounds bit strange have business logic depend on id's - think you'd want depend on entities - insert these entities , store generated id's duration of tests.
Comments
Post a Comment