EJBQL Schema

Previous Next Contents

D EJBQL Schema

The Jakarta Enterprise Beans, EJB-QL tests perform queries against a CMP 2.0 abstract persistence model that you deploy before you start the test runs.

Section 9.3.5, "EJB QL and SQL," in the EJB 3.1 Specification (http://jcp.org/en/jsr/detail?id=318) contains a sample mapping that shows how the Jakarta Platform, Enterprise Edition CI translates EJB QL to SQL, which helps to clarify the EJB QL semantics.

This appendix includes information about the following topics:

D.1 Persistence Schema Relationships

The figure, Figure E-1, below, contains detailed information about the persistence schema relationships.

Figure E-1 Persistence Schema Relationships

Persistence Schema Relationships

Note: EJB in the figure above is a references to Jakarta Enterprise Beans.

AliasEJB

String id;(pk)(cmp)
String alias;(cmp)
Customer customerNoop;(cmr)
Collection customersNoop;(cmr)
Collection customers;(cmr)

Country: DVC

String name;(cmp)
String code;(cmp)

AddressEJB

String id;(pk)(cmp)
String street;(cmp)
String city;(cmp)
String state;(cmp)
String zip;(cmp)
Collection phones;(cmr)

ProductEJB

String id;(pk)(cmp)
String name;(cmp)
float price;(cmp)
int quantity;(cmp)
long partNumber;(cmp)

CustomerEJB

String id;(pk)(cmp)
String name;(cmp)
Country country;(cmp)
AddressLocal home;(cmr)
AddressLocal work;(cmr)
Collection creditCards;(cmr)
Collection orders;(cmr)
Collection aliases;(cmr)
SpouseLocal spouse;(cmr)

CreditCardEJB

String id;(pk)(cmp)
String type;(cmp)
String expires;(cmp)
boolean approved;(cmp)
String number;(cmp)
OrderLocal order;(cmr)
CustomerLocal customer;(cmr)
double balance;(cmp)

InfoEJB

String id;(pk)(cmp)
String street;(cmp)
String city;(cmp)
String state;(cmp)
String zip;(cmp)
SpouseLocal spouse;(cmr)

OrderEJB

String id;(pk)(cmp)
float totalPrice;(cmp)
CustomerLocal customer;(cmr)
LineItemLocalsampleLineItem;(cmr)
Collection lineItems;(cmr)
CreditCardLocal creditCard;(cmr)

LineItemEJB

String id;(pk)(cmp)
int quantity;(cmp)
OrderLocal order;(cmr)
ProductLocal product;(cmr)

PhoneEJB

String id;(pk)(cmp)
String area:(cmp)
String number;(cmp)
AddressLocal  address;(cmr)

SpouseEJB

String id;(pk)(cmp)
String firstName;(cmp)
String maidenName;(cmp)
String lastName;(cmp)
String SocialSecurityNumber(cmp);
InfoLocal info;(cmr)
CustomerLocal customer;(cmr)

D.2 SQL Statements for CMP 1.1 Finders

Listed below are the SQL statements used for CMP 1.1 finders in:

  • ejb/ee/bb/entity/cmp/clientviewtest

  • interop/ejb/entity/cmp/clientviewtest

  • ejb/ee/bb/entity/cmp/complexpktest

  • ejb/ee/tx/txECMPbean

D.2.1 ejb/ee/bb/entity/cmp/clientviewtest, interop/ejb/entity/cmp/clientviewtest

<method-name>findWithinPrimaryKeyRange</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable" WHERE "KEY_ID" BETWEEN ?1 AND ?2</sql>
<method-name>findWithinPriceRange</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable" WHERE "PRICE" BETWEEN ?1 AND ?2</sql>
<method-name>findByName</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable" WHERE "BRAND_NAME" = ?1</sql>
<method-name>findAllBeans</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable"</sql>
<method-name>findByPrice</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable" WHERE "PRICE" = ?1</sql>
<method-name>findByNameSingle</method-name>
<sql>SELECT "KEY_ID" FROM "TestBeanEJBTable" WHERE "BRAND_NAME" = ?1</sql>

D.2.2 ejb/ee/bb/entity/cmp/complexpktest

<method-name>findByPrice</method-name>
<sql>SELECT "BRAND_NAME", "ID" FROM "TestBeanEJBTable" WHERE "PRICE" = ?1</sql>
<method-name>findById</method-name>
<sql>SELECT "BRAND_NAME", "ID" FROM "TestBeanEJBTable" WHERE "ID" = ?1</sql>
<method-name>findByName</method-name>
<sql>SELECT  "BRAND_NAME", "ID" FROM "TestBeanEJBTable" WHERE "BRAND_NAME" = ?1</sql>

D.2.3 ejb/ee/tx/txECMPbean

<method-name>findByName</method-name>
<sql>SELECT "KEY_ID" FROM "TxECMPBeanEJBTable" WHERE "BRAND_NAME" = ?1</sql>
<method-name>findWithinPrimaryKeyRange</method-name>
<sql>SELECT "KEY_ID" FROM "TxECMPBeanEJBTable" WHERE "PRICE" BETWEEN ?1 AND ?2</sql>
<method-name>findByPrice</method-name>
<sql>SELECT "KEY_ID" FROM "TxECMPBeanEJBTable" WHERE "PRICE" = ?1</sql>
<method-name>findWithinPrimaryKeyRange</method-name>
<sql>SELECT "KEY_ID" FROM "TxECMPBeanEJBTable" WHERE "KEY_ID" BETWEEN ?1 AND ?2</sql>

Previous Next Contents
Eclipse Foundation Logo  Copyright © 2018, 2020 Oracle and/or its affiliates. All rights reserved.