O'Reilly logo

Core Java™ Data Objects by Heiko Bobzin, Michael Vorburger, Keiron McCammon, Sameer Tyagi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.3. Defining a Class

The first step in using JDO is to create a persistence-capable Java class. For the purposes of the examples in this book, it is assumed that byte code enhancement is being used, so all that is needed is a Java class. The following code snippet shows the code for a class called Author, which represents the author of a book:

package com.corejdo.examples.model;

public class Author {

  private String name;

  public Author (String name) {

      this.name = name;
  }

  protected Author () {}

  public String getName () {

    return name;
  }

  public void setName (String name) {

    this.name = name;
  }
}

This class is relatively simply with just one string field. JDO can, of course, support much more than this; see Section 3.9 for more details on what is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required