Announcement Announcement Module
Collapse
No announcement yet.
OneToMany - Foreign key is not updated in the Owning table Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OneToMany - Foreign key is not updated in the Owning table

    The relationship is defined as follows:

    Owner table - Cache
    Code:
    	//bi-directional many-to-one association to Vendor
    	@OneToMany(mappedBy="cache",cascade = CascadeType.ALL)
    	private List<Vendor> vendors;
    Owned Table - Vendor
    Code:
    	//bi-directional many-to-one association to Cache
        @ManyToOne
    	@JoinColumn(name="KEY", referencedColumnName="VENDOR_KEY", updatable=false, insertable=false)
    	private Cache cache;
    The Cache table has a reference to the Vendor Ids
    Code:
    CREATE TABLE VENDOR ( KEY INTEGER...
    CREATE TABLE CACHE ( KEY INTEGER NOT NULL, VENDOR_KEY INTEGER,
    Vendor_Key is the foreign key.
    When I add a Cache having multiple vendors, the Keys are getting inserted but the VENDOR_KEY ( a foreign key) is not getting updated.
    I am using Eclipse Link, Spring Data.
    Thanks

  • #2
    Please ignore my question. I got it working by the unidirectional example in
    http://wiki.eclipse.org/EclipseLink/...ings/OneToMany
    Thanks

    Comment

    Working...
    X