• 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

Using JDO with an existing DB schema

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally speaking, how difficult is it with JDO to map to an existing relational schema? How does performance compare to a freshly created schema mapped directly through JDO?
 
Author
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDO has two forms of identity: datastore and application. Application identity is similar to primary keys in a relational database and all the JDO relational implementations support this. With an existing relational schema, you are not likely to have inheritance represented in your tables, so you would typically not have inheritance in your classes. Your foreign keys in the relational schema are mapped to references in your object model. A collection in a class A implies that there are multiple objects associated with it from a class B. At the relational level, this is normally represented by the B table having a foreign key referencing a row in table A (assume a 1-1 between class A/table A, class B/table B). So you can indicate that the foreign key in A serves as the inverse for establishing the collection elements in the collection in B. It is very late and I am tired, so forgive me if I am not making sense. The short answer is that you usually can map existing relational schemas to an object model.
Conversely, if you have an existing object model, it is fairly straightforward to map this to a relational schema. You also have the choice of using either datastore or application identity. With datastore identity, the JDO implementation takes care of generating unique identifiers for you. Also when letting JDO generate the relational schema, it can generate the proper table structures to represent inheritance relationships.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
edk,
Welcome to JavaRanch! We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks pardner. Hope to see you 'round the Ranch!
 
reply
    Bookmark Topic Watch Topic
  • New Topic