Professional Documents
Culture Documents
TM
Agenda
DEDE Overview
DEDE within eBox Architecture
DEDE Architecture: Flow
Persistent Entities
Main steps to use DEDE Plugin
Sample JPA Annotated DO
Demo
JPA Annotation
Association
DEDE main features
DEDE Plugin Testing Area
DEDE Plugin Automation Strategy
Best Practices
References
TM
DEDE Overview
DEDE :DAL Eclipse Development Environment
DEDE is an Eclipse plug-in designed to assist the developer in
providing persistence through the eBay Data Access Layer,
the DAL.
DEDE is similar to Object/Relational mapping tools like
Hibernate. It enables you to write object trees and retrieve
them from persistent storage.
DEDE partially automates the process of interfacing a Java
application to eBay's Data Access Layer, the DAL.
TM
V4 TOOL
DEDE TOOL
V4
SOA
DAL
kernel
TM
DOn
DAO Wizard
Generate
CGDIMPL
CGDIMPL
CGDIMPL
CGDIMPL n
DoImpl
DoImpl
DoImpl
DoImpl n
Generate
DAO n
Cache
Query
Engine
Databases
Business Object
10/08/15, p5, eBay Inc. Proprietary & Confidential
TM
Persistent Entities
A persistent entity can be thought of being made up of three
logical components: DO, DAO, and CodeGenDoImpl .
DO (Data Object): generally maps a POJO to a single row in a DB
table. Java properties in the DO generally correspond to columns in
the table.
DAO (Data Access Object): provides the functionality to perform basic
database operations - to retrieve objects (as DOs) from the database,
to insert DOs into the database, and to update or delete entities. The
DAO is a singleton, and is implemented as a single class.
CodeGenDoImpl: implements the DO interface, including getters and
setters. It also implements some DAL functionality such as dirty
tracking and lazy loading.
DEDE can also generate a DoImpl implementation class, a subclass
of CodeGenDoImpl
10/08/15, p6, eBay Inc. Proprietary & Confidential
TM
TM
package com.ebay.cookbook.department;
import javax.persistence.*;
import com.ebay.cookbook.person.Person;
@Entity
@Entity
@Table(name = "person")
@Table(name = "department")
@com.ebay.persistence.ConstantToupleProvider("ebox")
@com.ebay.persistence.Table(alias = "per")
@com.ebay.persistence.ConstantToupleProvider("ebox")
public interface Person {
@com.ebay.persistence.Table(alias = "dep")
public interface Department {
@Id
@Id
public int getId();
public int getId();
public void setId(int id);
@AlternateId
public void setId(int id);
@Column(name = "DriverLicense")
@Column(name = "name")
public String getDL();
public String getDepartmentName();
public void setDepartmentName(String
department);
@ManyToOne
@JoinColumn(name = "dept_id", referencedColumnName = "id")
public Department getDepart();
public void setDepart(Department department);
TM
DEDE
Demo
TM
JPA Annotation
@Entity means that the interface has a DEDE-managed mapping to a database table.
@Id identifies the Entity PK
@Table tells DEDE what name should be used for the table. (Optional)
@Column refers to the table column name. if no name is given, DEDE will use the usual JavaBean conventions to
determine the column name
@SecondaryTable Used when properties from a single DO are contained in two (or more) database tables. It causes
the Joins Page of the DAO editor to appear.
@GeneratedValue Specified on a property getter method that is also annotated with @Id. It indicates that the value
of this field will be set by the database engine
@AlternateID indicates that a field is an alternate key
@DerivedValue indicates that the field should not be automatically added to generated read and update sets
@Version -Only one field per entity can be annotated with @Version. The underlying column must be of a numeric
type
@Transient causes generation of simple property getter and setter methods, but hides field from DAL (no
FullFieldMapping is generated)
TM
JPA Annotation
@Hint / @HashHint Indicates field does not map to a database column, but will still have a mapping created for it so
that it will be visible
@Hint annotation is placed on individual Java property
@HashHint is placed on the interface
TM
JPA Annotation
@SelectExpression, @InsertExpression, @UpdateExpression provide values that will be
inserted into templatized SQL statements in place of the simple item name
@Column(name = "lastmodified")
@InsertExpression("sysdate()")
@UpdateExpression("lastmodified=sysdate()")
public Date getLastModifiedDate();
@com.ebay.persistence.Column(name = "preptime", alias = "avgprep")
@SelectExpression("avg(preptime)")
@DerivedValue
public int getAveragePreparationTime();
@JoinColumn is used with the association @OneToOne or @ManyToOne to provide non-default
names for the database columns
@JoinColumns grouping annotation is used when there is a composite key for the foreign entity
@ConstantToupleProvider
TM
TM
Association
@OneToOne is used to indicate an association with 1:1 multiplicity
@ManyToOne is used on the one side of a one-to-many association. It may
be accompanied by @JoinColumn / @JoinColumns to set names for the
database columns.
@OneToMany is used on the many side of a one-to-many association. In
our implementation, one-to-many relationships are always owned by the
one side (that is, there must be a column in the one side that holds the
foreign key value of the many side).
@ManyToMany
- DEDE does not support the JPA @ManyToMany annotation
-With JPA many-to-many, the join table is implicit, and is managed completely
by the JPA implementation
- For DEDE, many-to-many relationships can be modeled by explicitly
declaring the join table as an entity (creating a DO for it), with the JoinTable
having many-to-one relationships with both of the tables that participate in
the many-to-many relationship
TM
TM
Best Practices
Encourage the plugin developer to separatethe code into
(typically) three plug-ins:
1. CORE plug-in that contains the model and factory classes
2. PRESENTATION plug-in that contains the presentation
adapters, commands, etc.
3. UI plug-in that contains wizards, editors, menus, etc.
References
https://wiki2.arch.ebay.com/confluence/display/EBOX/Overall+testing+strategy
TM
Questions
TM