Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/MySports"

(Example Details)
Line 62: Line 62:
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}
 
|-{{BMTHStyle}}
 
|-{{BMTHStyle}}
! Class
+
! Class/Interface
 
! Description
 
! Description
 
|-
 
|-
Line 73: Line 73:
 
| Player
 
| Player
 
| A player represents a person within a specified team. A player is an extensible entity type.
 
| A player represents a person within a specified team. A player is an extensible entity type.
 +
<source lang="java">
 +
@Entity
 +
@Table(name = "mys_player")
 +
@Multitenant(MultitenantType.SINGLE_TABLE)
 +
@TenantDiscriminatorColumn(name = "LEAGUE_ID", contextProperty = LEAGUE_CONTEXT)
 +
@VirtualAccessMethods
 +
public class Player implements Extensible {
 +
</source>
 +
|-
 +
| Extensible
 +
|
 
|}
 
|}
  

Revision as of 10:56, 17 June 2011

EclipseLink MySports Example

The MySports example is a simple web application which demonstrates several key features of

EclipseLink including:

  • EclipseLink JPA
    • @Multitenant(SINGLE_TABLE)
    • Extensible entities with @VirtualAccessMethods

Example Overview

The example includes 3 projects

  1. MySports: A Dynamic Web project which deploys the primary application exposing a JSF and

JAX-RS (REST) front end.

  1. MySports Admin:
  2. MySports Tests: A Java project containing Junit tests that verify the functionality of

Install & Config

At present the example is only available through SVN access. When completed a ZIP download will be made available.

Basic Steps

  1. Prepare Prerequisites:
    1. GlassFish 3.1
    2. Eclipse Java EE with GlassFish adapter
  2. Configure Eclipse
    1. Requires a variable named 'eclispelink_2.3_jar' for the javaagent usage of the test project
    2. Ensure you have a GlassFish Server configured in the Java EE perspective
  3. Configure GlassFish
    1. EclipseLink 2.3 bundles installed in GlassFish
    2. A connection pool named 'jdbc/MySports' must be defined in the server
  4. Get the example's projects
    1. Import the projects
    2. Customize the eclipselink-examples-mysports.properties file for your database
  5. Run The example
    1. Run the MySports AllTests launch target. This will create the database tables and prepare an initial population
    2. Run the MySports Admin application
    3. Run the MySports application

Example Details

MySports Domain

The domain model is that of any arbitrary sports league. The idea is that this SaaS

solution allows any league to host its information on the site and customize the data

stored as well as the look and feel.

Class/Interface Description
Division A league contains one or more divisions of teams used to divide teams by age, skill or simply to manage a larger set of teams.
Team A team belongs to a division and has a name and players.
Player A player represents a person within a specified team. A player is an extensible entity type.
@Entity
@Table(name = "mys_player")
@Multitenant(MultitenantType.SINGLE_TABLE)
@TenantDiscriminatorColumn(name = "LEAGUE_ID", contextProperty = LEAGUE_CONTEXT)
@VirtualAccessMethods
public class Player implements Extensible {
Extensible


Persistence

The persistence layer is the main purpose of this example application. The persistence layer makes use of application bootstrapped persistence contexts with support for an EntityManagerFactory and backing ServerSession (with Cache) per league (tenant). This all bootstrapped off of a single persistence-unit definition.

Mysports persistence.png