• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is setMovies(null) valid?

 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for cmr collection field, i learnt from somewhere in mock question saying that we have to use an empty Collection/Set as the argument in stead of null, in order to de-associate the movies with the director, is that correct?
director 1 ------ 0..* movie
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yi,
Answer to your question is in section 10.3.8 on p. 155 of the specifications :
It is the responsibility of the Container to raise the java.lang.IllegalArgumentException
if the Bean Provider attempts to assign null as the value of a collection-valued
cmr-field by means of the set accessor method.

To clear one director's movies, I'd simply call getMovies().clear().
Regards,
Phil.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic