• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Hibernate Mapping for id

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have configuration doubt in hibernate.

please look into my configuration


according to above configuration whenever i save CreditCard.java , next sequence id is generated
now , i tried to set id manually by setting



but still it generate next sequence id and getting saved.
please let me know how to configure it accordingly ?

thanks for all your help in advance...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jayaraj Jaganathan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
1. sequence
2. assigned

 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two mappings for the same entity so you can use two different id generation strategies? Why?
 
Jayaraj Jaganathan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic