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

ManyToOne relation with composite keys

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am having problems with JPA using Toplink. I have used the default generated code for entities with NetBeans 6.1.

There are three tables defined in MySQL as




The entities generated lead rightly to Composite Keys with @Embedded and EmbeddedID annotations for the tables FilesOnServer and FolderDetails with additional entities FilesOnServerPK FolderDetailsPK .

I persist the relationship (between the FilesOnServer and FolderDetails entities with the code below



The FileOnServer entity is persisted without error but the PARENT_ID field remains null when I was expecting it to be updated with the FOLDER_ID field from the FolderDetails Table/entity.


In the log the following sql command appears
INSERT INTO files_on_server (FILENAME, FILESIZE, FILE_ID, AUTO_UID) VALUES (?, ?, ?, ?)
bind => [n0n0n.txt, 51, 1001, 1]


The thing I noted it that there is no refernce to the PARENT_ID column here...


Any ideas what I may be doing wrong?

Thanks
 
Kulbhushan Sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No response.

The workaround we use is to expand the primary key for FilesOnServer to also include the ParentID which works but is a hack.
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic