相关文章推荐
闷骚的紫菜  ·  JSch - ...·  1 年前    · 
私奔的红烧肉  ·  element-ui ...·  1 年前    · 
飞翔的感冒药  ·  Oracle Application ...·  2 年前    · 
We’re sorry. We could not find a match for your search.

We suggest you try the following to help find what you’re looking for:

  • Check the spelling of your keyword search.
  • Use synonyms for the keyword you typed, for example, try "application" instead of "software."
  • Start a new search.
  • TopLink may create entity identifiers (or primary keys) automatically using any of the following strategies defined by JPA:

  • Sequence objects
  • Identity Columns
  • Tables
  • Provider-assigned strategy
  • TopLink JPA can produce a default sequence during schema generation. If you use schema generation, then specify that your identifier should be generated and that the SEQUENCE strategy be used to perform the generation. In the following example, the @GeneratedValue annotation indicates that the identifier value should be automatically generated; a strategy of SEQUENCE indicates that a database sequence should be used to generate the identifier. TopLink will create a default sequence object during schema generation. This object will be used by TopLink at run time.

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private long id;

    To use a specific named sequence object, whether it is generated by schema generation or already exists in the database, you must define a sequence generator using a @SequenceGenerator annotation. You may choose any unique label as the name for the sequence generator. Reference this name by the generator element in the @GeneratedValue annotation. Also, include the sequenceName element to specify the name of the database sequence object that you are using.

    If the sequence object already exists in the database, then you must specify the allocationSize to match the INCREMENT value of the database sequence object. For example, if you have a sequence object that you defined to INCREMENT BY 5, set the allocationSize to 5 in the sequence generator definition, as the following example shows:

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(generator="InvSeq")
    @SequenceGenerator(name="InvSeq",sequenceName="INV_SEQ", allocationSize=5)
    private long id;

    When using a database that does not support sequences, but does support identity columns (such as SQL Server database), you can configure JPA to use an identity column to generate identifiers.

    To enable generation of identifiers using identity columns, specify a strategy of IDENTITY. In the following example, the @GeneratedValue annotation indicates that the identifier value should be automatically generated, and the specified strategy of IDENTITY indicates that an identity column should be used to generate the identifier:

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private long id;

    During schema generation, TopLink JPA can generate a default table for identifier generation. If you use schema generation, then specify a strategy of TABLE in the @GeneratedValue annotation, as the following example demonstrates. TopLink will create a default table during schema generation. This table will be used by TopLink at run time:

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(strategy=GenerationType.TABLE)
    private long id;

    To map to an existing table or cause the table object generated by schema generation to be given a particular name, define a table generator using a @TableGenerator annotation.

    The table generator has a name, by which it is referenced in the @GeneratedValue annotation. The generator also lists the name of the specific database table, as well as the names of the key and value columns used to store identifier generators in the table. Each row in the table represents the generator for a particular entity type, with the value in the key column indicating the entity type. The generator for Inventory instances might have a key of INV_GEN, as the following example shows:

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(generator="InvTab")
    @TableGenerator(name="InvTab", table="ID_GEN",
    pkColumnName="ID_NAME", valueColumnName="ID_VAL",
    pkColumnValue="INV_GEN")
    private long id;

    The table generator defined in the preceding example would be mapped to the following table:

    ID_GEN

    ID_NAME ID_VAL INV_GEN <last generated value >

    By specifying a strategy of AUTO you are indicating your intention to let TopLink pick the strategy to use. Typically, TopLink picks TABLE as the strategy, since it is the most portable strategy available (it does not lock you into a particular database). However, when AUTO is specified, schema generation must be used at least once in order for the default table to be created in the database.

    The following example demonstrates the use of the AUTO strategy:

    @Entity
    public class Inventory implements Serializable {
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;

    JPA and NoSQL

    The Java Persistence specification is an API (JPA) for creating, removing and querying across lightweight Java objects and can be used both within a compliant EJB 3.0 Container and a standard Java SE 5 environment. Oracle TopLink is a leader in the JPA community delivering the JPA 1.0, 2.0, and 2.1 reference implementations and now having developed the JPA 2.0 reference implementation with EclipseLink.

    Starting with Oracle TopLink 12.1.2 developers can now access NoSQL data through TopLink's NoSQL mapping and persistence API.

  • Read Preview Chapter of: Pro EJB 3.0 Java Persistence API
  • Chapter 2: Getting Started
  • Tutorials
  • Building a Web Application (JSF) using JPA
  • Migrating to EclipseLink JPA from TopLink Essentials
  • JSR 220: Download the JPA 1.0 Specification
  • JSR 317: Download the JPA 2.0 Draft Specification
  • EclipseLink JPA User Guide
  • Resources

    Java Persistence API (JPA) and TopLink JPA.

    Valuable resources for developers using the Java Persistence API (JPA) and TopLink JPA.

    Pro EJB 3 - Java Persistence API

    The first JPA book available by Oracle's own Mike Keith and Merrick Schincariol.

    A close look at annotations and specific use cases of employing annotations and XML as a metadata language. by Mike Keith

    How to use JPA in new or existing Spring applications to achieve standardized persistence. byMike Keith and Rod Johnson - April 30, 2007

    See how to address the migration concerns of enterprise application developers and architects who are currently using EJB 2.1 CMP. by Merrick Schincariol and Doug Clarke - June 22, 2005

    An example illustrating basic JPA mapping, querying, and entity lifecycle management in a Java Server Faces Web application.

  • order-jsf-jpa-example.zip
  • SRDemo: This is an update to the Service Request Demo  provided with the 10.1.3.0 release. The version migrates the persistence from proprietary TopLink to TopLink JPA using annotations for all mappings and entity configuration.
    Coming Soon