views:

26

answers:

1

I have a situation where I have a class that is referenced by several other classes. For example, my ContactInformation class is referenced by multiple different classes, such as Customer, Business, Location, etc. Since it is referenced by multiple classes, I am unsure of how to make a two-way mapping so I can insert a Customer with its Contact Information. As a result, I am getting an error on insert because ContactInformation is seen as null.

Has anybody ever run into a situation like this? Thanks for any help!

+1  A: 

I would map the ContactInformation as a many-to-one with cascade="all". When you create a new Customer you'll need to also create a new ContactInformation (unless it allows nulls). Then when you SaveOrUpdate the Customer it will cascade and SaveOrUpdate the ContactInformation.

dotjoe
DOH! I omitted the cascade attribute. Thanks!
Mike C.