• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate EntityManager working with Collections

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an entity (InvalidAddress) with a many to one relationship with another entity (ServiceRequest). I am trying to add an InvalidAddress entity to the InvalidAddressCollection owned by ServiceRequest



I am getting a NPE because serviceRequest.getInvalidAddressCollection() is returning null when there are no related InvalidAddress entities. I know this makes sense but it seems like a waste to have to do this before I add any related entity to any collection



Is this very repetitive boiler-plate required when working with collections?

It would seem like the EntityManager should initialize the Collection and just return an empty list instead of a null list. Or is that up to me when I implement the getter on ServiceRequest?

Thanks for any advice.
[ July 23, 2007: Message edited by: Brian Smith ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic