• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Primary Key no args constructor BMP, mandatory?

 
andy armstrong
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In O"Reilly book Entreprise JavaBeans(pg 158)
he states that..
"The no-argument constructor is required for container managed persistence".
Shouldn't it also be required for BMP?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Andy,
In CMP the primary-key is instanciated by the container, that is why it needs a no-argument constructor. (the container will do the job to find a correct unique id for this PK).
While in BMP the primary key is instantiated by you, then it is not required to be a no-argument constructor.
It is your job to be sure that you got a unique id for this PK, (usually via a idProvider that pooled numbers of unique id). Therefore a BMP primary key usually take an int or a long as contructor argument.
Hope this is clear !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic