hilo

Enable Hibernate HiLo Strategy

Deadly 提交于 2019-12-06 09:57:38
问题 I'm initializing Hibernate without any XML by something like org.hibernate.SessionFactory sessionFactory = new org.hibernate.cfg.Configuration(). .setProperty(...) .setProperty(...) ... .buildSessionFactory(); My classes use an ID like @Id @Generated(GenerationTime.INSERT) @GeneratedValue private Integer id; The generator used is SequenceStyleGenerator , which seems to be the replacement for the deprecated SequenceGenerator and SequenceHiLoGenerator and whatever. It uses public static final

NHibernate Hi/Lo - gaps in ids

一笑奈何 提交于 2019-12-06 08:25:25
Scenario: Hi/Lo is initialized for MyEntity with Lo 100 The table is empty. Two sessions with different connections have both inserted three items. TableIds 1 2 3 100 101 102 If a third one comes in at a later time and inserts three items: TableIds ... 200 201 202 Is there a way to not get these gaps? The Lo value is stored against the SessionFactory, not the Session. You only ever get gaps when you restart your application and create a new instance of the SessionFactory. A new Hi value is pulled from the database and stored in the SessionFactory, so if you have a web farm, each site will have

NHibernate HiLo generation and SQL 2005/8 Schemas

醉酒当歌 提交于 2019-12-06 07:17:59
I have an issue on my hands that I've spent several days searching for an answer to no avail... We're using HiLo Id generation, and everything seems to be working fine, as long as the entity table is in the same schema as the hibernate_unique_key table. The table structure is pretty simple. I have my hi value table in the db as dbo.hibernate_unique_key. Several entity table are also in the dbo schema, and they work without issue. Then we have tables under the "Contact" schema (such as Contact.Person and Contact.Address). In the Person Mapping file: <class name="Person" table="Person" schema=

HiLo or identity?

痴心易碎 提交于 2019-12-06 06:48:36
问题 Just wanted to get some opinions on primary keys - would it be better to use identity/sequence numbers or use a HiLo strategy (query for the high value and increment the low value on the app itself)? 回答1: If your application is only going to use one database, I'd go with an identity/sequence. The only really compelling reason to go with HiLo that I've seen is when you could have two disconnected instances of your application that people can work on simultaneously and you need to reconcile the

NHibernate HiLo - new column per entity and HiLo catches

孤人 提交于 2019-12-05 20:24:26
问题 I'm currently using the hilo id generator for my classes but have just been using the minimal of settings eg <class name="ClassA"> <id name="Id" column="id" unsaved-value="0"> <generator class="hilo" /> </id> ... But should I really be specifying a new column for NHibernate to use foreach entity and providing it with a max lo? <class name="ClassA"> <id name="Id" column="id" unsaved-value="0"> <generator class="hilo"> <param name="table">hibernate_unique_key</param> <param name="column">classA

HiLo or identity?

时光怂恿深爱的人放手 提交于 2019-12-04 13:21:41
Just wanted to get some opinions on primary keys - would it be better to use identity/sequence numbers or use a HiLo strategy (query for the high value and increment the low value on the app itself)? If your application is only going to use one database, I'd go with an identity/sequence. The only really compelling reason to go with HiLo that I've seen is when you could have two disconnected instances of your application that people can work on simultaneously and you need to reconcile the differences at some point Ex . You are working on a content management system where people could be working

What are all the NHibernate HiLo generator params?

好久不见. 提交于 2019-12-04 03:12:24
I've seen some docs by Fabio Maulo that shows the following params: <id name="Id" type="Int64" column="cat_id"> <generator class="hilo"> <param name="table">hi_value</param> <param name="column">next_value</param> <param name="max_lo">100</param> </generator> </id> However, on this question the poster uses a <param name="schema">... I'd like to be able to specify schema for the HiLo generator. Is there definitive documentation for all generator parameters? I've tried googling it without success. Another param to throw in the mix is <param name="where">TableName='CmsLogin'</param> This gives

Error with hilo in NHibernate - “could not read a hi value - you need to populate the table”

筅森魡賤 提交于 2019-12-03 07:14:48
I've genereated a schema for my (SQL 2005) db using SchemaExport, and it's created a table CREATE TABLE [dbo].[hibernate_unique_key]( [next_hi] [int] NULL ) ON [PRIMARY] When I try to add an entity, I get the error "could not read a hi value - you need to populate the table". What am I meant to do? edit: I've inserted a 1 into the table, and it seems to work. Is this the correct value to have in there? NHibernate expects to find a value that stores the current hi value in that table, ie it first runs something like: current_hi = [SELECT max(next_hi) FROM hibernate_unique_key]. So all you need

Is there a practical way of migrating from identity columns to hilo keys?

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:07:00
问题 I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be recommended with NHibernate. Are there any strategies to do this, or any common problems to watch out for? 回答1: If this is a question about migrating an existing application to hilos which previously used auto ids, and has old data in it which needs to be migrated... then this would be my best bet (not tried it though

Is there a practical way of migrating from identity columns to hilo keys?

落爺英雄遲暮 提交于 2019-12-02 19:28:33
I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be recommended with NHibernate. Are there any strategies to do this, or any common problems to watch out for? If this is a question about migrating an existing application to hilos which previously used auto ids, and has old data in it which needs to be migrated... then this would be my best bet (not tried it though! - comments welcome!) : Change your column types ids to bigints find out highest id value currently in any