Paul Sturrock wrote:What configuration do you want to use? You can either use a generator and delegate to something else to create an id or you can define the id as "assigned" and assign it yourself, you can't do both.
thanks for your reply
so i planned to have two hbm files
Two mappings for the same entity so you can use two different id generation strategies? Why?
Joined: Jun 29, 2009
Paul Sturrock wrote:Two mappings for the same entity so you can use two different id generation strategies? Why?
its complected to explain, let me try
existing design (shopping cart)
when user submit order we store client credit card information in database, here we no need to assign an id, so we used sequence
new requirement (new shopping cart)
when user submit order we need to call fraud web service after that we store client credit card information in database,
here fraud web service need credit card id as the request, so we are going to use assigned
So, your CC fraud service needs the surrogate key of your credit card entity? Not sure I understand why; but I'll take your word for it (though if your CC fraud service returns a value with business meaning you probably don't want that as your key).
Sounds like you just can't use a generated key. I'd swap to assigned; its just asking for bugs to have two entities and calling different ones dependent on where in your code you persist.