This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Primary Key no args constructor BMP, mandatory?  RSS feed

 
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 !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!