views:

74

answers:

1

I'm connecting to a legacy database that is our ERP system. I have a table that is using composite keys and one of those fields is incremented but it is unique within a subgroup of records. I have no ability to change this although I wish I could.

For example, CustomerId_Field, SequenceID_Field 49, 1 49, 2 200, 1 200, 2 200, 3 200, 4

The typical insert of this MULTI-USER application looks like this: INSERT INTO MYTABLE(CustomerId_Field, SequenceID_Field) VALUES (?CustomerId_Field, SELECT MAX(SequenceID_Field) + 1 WHERE CustomerId_Field = ?CustomerId_Field);

It is my understanding that using increment with key generation will accomplish something like this but it seems to me that increment is only geared for incrementing one column that is unique over an entire table. What is the best way to handle my situation and how?

Thank You.

A: 

You need to generate the key yourself, and give it to NH.

Dani
Does this mean that I need to create a custom generator class from interface IIdentifierGenerator? If so, will it work within a composite key framework?
Brian