JDO and object-relational mapping

This example uses the Java Data Objects (JDO) Binding. Notice that all the code is Java. You will not find a database sub-language in this example. The part in blue relates to the animation of transparent persistence (new window). Note that the same code would used for object databases (new window). Transparent persistent interfaces work with both object database or object-relational mapping products.

import javax.jdo.*;
import java.util.Collection;
PersistenceManagerFactory pmf; // assume this variable is set
pmf.setConnectionUserName("  ");
pmf.setConnectionPassword("  ");
pmf.setConnectionURL("database URL");
PersistenceManager pm = pmf.getPersistenceManager();
Transaction txn = pm.currentTransaction();
txn.begin();
Collection people = pm.getExtent(Person.class, false);
// perform query
Query query = pm.newQuery(Person.class, people, "name == \"Doug Barry\"");
Collection result = (Collection) query.execute();
    Iterator iter = result.iterator();
    // iterate over the results
    while ( iter.hasNext() )
    {
        Person person = (Person) iter.next();
        // do some addition processing on the person (not shown)
        // now traverse to the address object and update its value
        person.address.street = "13504 4th Avenue South";
    }
txn.commit();

 

 

Web Services and Service-Oriented Architectures
Online articles>
Consulting
Mentoring
Speaking
Suggested programs
Stencils for the Savvy Manager's Guide
Links
Mail list
Privacy policy
Sitemap
Contact
Web Services articles
XML standards and vocabularies
Application server articles
Database concepts and standards
Object database articles
Relational database articles
Object-relational mapping articles>
XML database articles
XML middleware articles
Article Sponsorship
Reprint policy
Object-relational mapping (OR mapping) definition>
When object-relational mapping should be used
Mapping layer
Writing your own mapping layer
Using existing relational schema
Article suggestions
Transparent persistence in object-relational mapping
Transparent persistence vs. JDBC call-level interfaces
How to access data in a relational database>
Navigation with object-relational mapping
Java and object-relational mapping
JDO and object-relational mapping>
C++ and object-relational mapping

Related recent articles from Google News


DataNucleus Launched as Successor to Java Persistence Platform JPOX
InfoQ.com, Canada - May 1, 2008
Support for basic JDOQL querying of objects stored in LDAP via JDO. Support for persistence of Java objects to Excel via JDO/JPA APIs, utilizing Apache POI. ...

Java Developer
Bizcommunity.com, South Africa - Apr 9, 2008
A Cape Town based IT company requires a Java Developer with Java programming and syntax experience. Object Relational Mapping (Hibernate, JDO), ...

Java ORM Data Mapping Eclipse Plug-in Due
Integration Developers, CA - Apr 11, 2008
... development tools to ease round-trip engineering when using the JSR 220 (EJB 3.0 persistence) and JSR 243 (Java Data Objects) approaches to persistence. ...

Versant Aims To Ease Data-Driven Projects
Integration Developers, CA - Apr 10, 2008
EJBs JDO, and SQL . We support all those, and will support EJB 3.0 as soon as it's a standard But more than that, we let you mix and match your approaches ...
Tips & Tricks: A Cross-DB Resource Guide Integration Developers
all 6 news articles

More related news: Java JDO OR "Java Data Objects" - Google News

Related books at Amazon.com


Object-oriented Data Structures Using Java
by Nell B. Dale, Daniel T. Joyce, Chip Weems
Average Customer Review: 3.5 stars based on 3 reviews.
Customer Review: This seller was very punctual with the shipping and delivery of the book and it was in very good condition like the ad had stipulated. I will recomment him to anyone ST

Objects, Abstraction, Data Structures and Design: Using Java version 5.0
by Elliot B. Koffman, Paul A. T. Wolfgang
Average Customer Review: 4 stars based on 2 reviews.
Customer Review: Fails to address threading/concurrency issues. You will not find coverage of the new Concurrency Utilities including the new collection classes in package java.util.concurrent. You will not find the following terms in the index: concurrency synchronized thread thread-safe

Java Data Objects
by David Jordan, Craig Russell
Average Customer Review: 3.5 stars based on 11 reviews.
Customer Review: This book is definitely the best on java data objects! i have read the one from prentice hall and addison wesley`s. its true that the first code example doesnt work, what is a shame but if you overcome your frustration and have a look at the oreilly website you can fond the correct and again detailed information (and even reason) to...

Objects, Abstraction, Data Structures and Design: Using Java
by Elliot B. Koffman, Paul A. T. Wolfgang
Publisher: Wiley
Publication Date: August 2004

Data Structures and Software Development in an Object Oriented Domain, Java Edition
by Jean-Paul Tremblay, Grant A. Cheston
Publisher: Prentice Hall
Publication Date: August 2002

More related books: Search Amazon.com for "Java Data Objects"

 

Copyright © 2000-2008 Barry & Associates, Inc. All Rights Reserved.
You can use this material for your work or classes. Click here for our reprint policy.
www.service-architecture.com

 

 Information on becoming a sponsor

 

 

Google

 

Barry & Associates, Inc.