What is EJBQL stands for - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

What is EJBQL stands for

Description:

public abstract class StudentBean implements javax.ejb.EntityBean ... (but java.util.Calendar class can convert to long) Inheritance not supported. ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 17
Provided by: cmpeBo
Category:
Tags: ejbql | class | stands

less

Transcript and Presenter's Notes

Title: What is EJBQL stands for


1
What is EJB-QL stands for?
  • Enterprise Java Beans
  • QUERY LANGUAGE

2
Why an EJB-Query Language ?
  • No standard way to define queries with
    container-managed persistence.
  • EJB container providers have their own
    DB-systems and query syntax.
  • So, portability optimization problems between
    containers.

3
EJB Query Language is
  • an SQL like language(EJB QL select_clause
    from_clause where_clause)
  • a portable query language for EJB 2.0
  • a specification which can be compiled into the
    target platforms language.

4
How to use EJB-QL ?
  • How to define Relationships among Beans?
  • Defined Keywords.
  • How to write QUERY ?

5
Example system
6
STUDENT to TAKE_COURSE relation in deployment
descriptor
  • ltrelationshipsgt ltejb-relationgt  ltejb-relatio
    n-namegtTAKE_COURSE-STUDENTlt/ejb-relation-namegt  lt
    ejb-relationship-rolegt    ltejb-relationship-role-
    namegt course-takenBy-students  lt/ejb-relationship-
    role-namegt    ltmultiplicitygtManylt/multiplicitygt 
       ltrelationship-role-sourcegt      ltejb-namegtTake
    _CourseEJBlt/ejb-namegt    lt/relationship-role-sour
    cegt    ltcmr-fieldgt      ltcmr-field-namegt
    studentslt/cmr-field-namegt      ltcmr-field-typegt
    Student  lt/cmr-field-typegt    lt/cmr-fieldgt  lt/ej
    b-relationship-rolegtlt/ejb-relationgtlt/relation
    shipsgt

7
  • ltrelationshipsgt ltejb-relationgt  ltejb-relatio
    n-namegtSTUDENT-TAKE_COURSElt/ejb-relation-namegt  lt
    ejb-relationship-rolegt    ltejb-relationship-role-
    namegt student-take-course  lt/ejb-relationship-role
    -namegt    ltmultiplicitygtOnelt/multiplicitygt    ltr
    elationship-role-sourcegt      ltejb-namegtStudentEJ
    Blt/ejb-namegt    lt/relationship-role-sourcegt    lt
    cmr-fieldgt      ltcmr-field-namegt
    takenCourseslt/cmr-field-namegt      ltcmr-field-typ
    egt Take_Course  lt/cmr-field-typegt    lt/cmr-fieldgt
      lt/ejb-relationship-rolegtlt/ejb-relationgtlt/r
    elationshipsgt

8
Available query keywords
EJB-QL covers a subset of SQL92.
9
Query Example 1
  • SELECT OBJECT(s)
  • FROM STUDENT s
  • Method findall()

10
Query Example 2
  • SELECT DISTINCT OBJECT(s)
  • FROM STUDENT s
  • WHERE s.department ?1
  • Method findByDepartment(String department)

11
Query Example 3
  • SELECT DISTINCT c.name
  • FROM STUDENT s, IN (s.courses) AS c
  • WHERE s ?1
  • Method ejbSelectCourseNames
  • (LocalStudent student)

12
Query Example 4
  • SELECT DISTINCT OBJECT(s)
  • FROM STUDENT s, IN (s.courses) AS c
  • WHERE c.instructor ?1
  • Method findByInstructor(String instructor)

13
Query 4 in deployment descriptor
  • ltquerygtltdescriptiongtMethod to find students who
    takes course from a given instructorlt/descriptiongt
      ltquery-methodgt    ltmethod-namegtfindByInstructo
    rlt/method-namegt    ltmethod-paramsgt      ltmethod-
    paramgtStringlt/method-paramgt    lt/method-paramsgt  
      lt/query-methodgtltresult-type-mappinggtLocalStude
    ntlt/result-type-mappinggt  ltejb-qlgt
  • SELECT DISTINCT OBJECT(s)
  • FROM STUDENT s, IN (s.courses) AS c
  • WHERE c.instructor ?1 lt/ejb-qlgt
  • lt/querygt

14
Query 4 in StudentEJB
  • public abstract class StudentBean implements
    javax.ejb.EntityBean
  • ...
  • public abstract java.util.Collection
    selectByInstructor
  • (String instructor) throws FinderException

15
Restrictions of EJB-QL
  • No comments allowed.
  • Date and time in Java long format. (but
    java.util.Calendar class can convert to long)
  • Inheritance not supported.
  • Not all SQL features are supported.(Yet)(example
    GROUP BY, ORDER BY)

16
Questions ?
  • Kerem Basol
  • Ö. Bilal Orhan
Write a Comment
User Comments (0)
About PowerShow.com