I have a database relationship of two objects. The tables/objects are Company and Contact.
Company has a foreign key relationship with Contact. Therefore Contact has a company property. This field is required, or not nullable.
What I am trying to do is create a contact from scratch, populate the company property with a new company (minus the @Id primary key fields) and submit them to the entity manager.. Hoping that it will create new records in each table and build the relationship between the two.
is this possibly by using em.persist(contact); ? Or do I need to persist them both individually and create the relationship manually?
of course use cascade=PERSIST on the relationship