开发者

SchemaExport vs HiLo algorithm

I'm using schemaExport to create an in-memory database for my automatic tests. I have several (5) classes mapping their HiLo identity to the same database table, using one column per class.

This gives me a table, hibernate_unique_key, w. 5 columns. When generating the database using scemaexport, however, the table only gets a single column (IPoolActivation), thereby making my querys fail, since the mappings in the model are now invalid. I've tried manually querying the in memory database to create the table, but I would ra开发者_如何学Cther know how to make schemaexport do it right.

A snippet from one of my mapping files;

<id name="Id" column="Id" type="Int32">
  <generator class="hilo">
    <param name="column">IENPool</param>
  </generator>
</id>

What is the proper way to do this?


I believe there is a bug (or it is by design) in SchemaExport, and it only looks at the hibernate_unique_key table once when it sees the first entity with HiLo. As a result all HiLo entities must use the same column.

However, I recently needed a custom IdGenerator which I based off the same base class in NHibernate that HiLo inherits from. For this database I needed one column per table (it was for a legacy database that was setup with a HiLo style generator that way).

You can see what I did here if it helps:

Implementing a custom id Generator for nHibernate

Generate custom DDL for a custom id Generator

Entire post on nhibernate.info

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜