• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF RJB - Page 549 - Error ??

 
sopal Pal
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DuplicateKeyException Paragraph
- Should not the text be
......certain that the bean was created
Rather than as in the book which says
.....certain that the bean was NOT Created
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- well now that you pointed this out, I can see that it's confusingly-worded. It's not an error, though, but it needs a little more explanation:
The point of that page is to show the result to the CLIENT for whatever action caused the exception.
If the client gets a DuplicateKeyException on a create() call, then the client can be CERTAIN the bean that the client was trying to create was NOT created.
But it IS confusing, because it DOES mean that at some earlier point, an entity with that key *was* created. But that doesn't necessarily mean that a *bean* with that key was created. The Container can throw that exception if the Container finds that it cannot do an INSERT of an entity in the database because there is already something with that same key. So it's possible that no bean was ever officially *created* or *realized* (loaded and populated) but that the entity does exist already in the database, so that when the client calls create() on a bean's Home, the Container is unable to do the INSERT, and thus no bean is created.
Does that help?
Good question! Thanks for pointing this out.
cheers,
Kathy
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic