// Path: app/tennistour-core/src/main/java/com/mgreau/tennistour/core/entities/Player.java
// @Entity
// @Table(name = "PLAYER", uniqueConstraints = @UniqueConstraint(columnNames = { "NAME" }))
// @XmlRootElement
// @NamedQueries({
//       @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
//       @NamedQuery(name = "Player.findById", query = "SELECT p FROM Player p WHERE p.id = :id"),
//       @NamedQuery(name = "Player.findBySexe", query = "SELECT p FROM Player p WHERE p.sexe = :sexe"),
//       @NamedQuery(name = "Player.findByName", query = "SELECT p FROM Player p WHERE p.name = :name") })
// public class Player implements Serializable
// {
//    private static final long serialVersionUID = 1L;
// 
//    @Id
//    @Basic(optional = false)
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    private Integer id;
// 
//    @Basic(optional = false)
//    @NotNull
//    @Size(min = 1, max = 50)
//    private String name;
// 
//    @Basic(optional = false)
//    @NotNull
//    private Character sexe;
// 
//    public Player()
//    {
// 
//    }
// 
//    public Integer getId()
//    {
//       return id;
//    }
// 
//    public void setId(Integer id)
//    {
//       this.id = id;
//    }
// 
//    public String getName()
//    {
//       return name;
//    }
// 
//    public void setName(String name)
//    {
//       this.name = name;
//    }
// 
//    public Character getSexe()
//    {
//       return sexe;
//    }
// 
//    public void setSexe(Character sexe)
//    {
//       this.sexe = sexe;
//    }
// 
//    @Override
//    public int hashCode()
//    {
//       int hash = 0;
//       hash += (id != null ? id.hashCode() : 0);
//       return hash;
//    }
// 
//    @Override
//    public boolean equals(Object object)
//    {
//       if (!(object instanceof Player))
//       {
//          return false;
//       }
//       Player other = (Player) object;
//       if ((this.id == null && other.id != null)
//             || (this.id != null && !this.id.equals(other.id)))
//       {
//          return false;
//       }
//       else if (this.id == null && other.id == null)
//       {
//          if (this.name != null && other.name != null
//                && this.name.equals(other.name))
//             return true;
//       }
//       return false;
//    }
// 
//    @Override
//    public String toString()
//    {
//       return "Player@" + hashCode() + "[id = " + id + "; name = " + name
//             + "]";
//    }
// 
// }


import com.mgreau.tennistour.core.entities.Player;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;
{
   @PersistenceContext(unitName = "tennistour")
   private EntityManager em;

   @POST
   @Consumes("application/json")
   public Response create(Player entity)
   {
      em.persist(entity);
      return Response.created(UriBuilder.fromResource(PlayerEndpoint.class).path(String.valueOf(entity.getId())).build()).build();
   }

   @DELETE
   @Path("/{id:[0-9][0-9]*}")
   public Response deleteById(@PathParam("id") Integer id)
   {
      Player entity = em.find(Player.class, id);
      if (entity == null)
      {
         return Response.status(Status.NOT_FOUND).build();
      }
      em.remove(entity);
      return Response.noContent().build();
   }

   @GET
   @Path("/{id:[0-9][0-9]*}")
   @Produces("application/json")
   public Response findById(@PathParam("id") Integer id)
   {
// Path: app/tennistour-core/src/main/java/com/mgreau/tennistour/core/entities/Player.java
// @Entity
// @Table(name = "PLAYER", uniqueConstraints = @UniqueConstraint(columnNames = { "NAME" }))
// @XmlRootElement
// @NamedQueries({
//       @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
//       @NamedQuery(name = "Player.findById", query = "SELECT p FROM Player p WHERE p.id = :id"),
//       @NamedQuery(name = "Player.findBySexe", query = "SELECT p FROM Player p WHERE p.sexe = :sexe"),
//       @NamedQuery(name = "Player.findByName", query = "SELECT p FROM Player p WHERE p.name = :name") })
// public class Player implements Serializable
// {
//    private static final long serialVersionUID = 1L;
// 
//    @Id
//    @Basic(optional = false)
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    private Integer id;
// 
//    @Basic(optional = false)
//    @NotNull
//    @Size(min = 1, max = 50)
//    private String name;
// 
//    @Basic(optional = false)
//    @NotNull
//    private Character sexe;
// 
//    public Player()
//    {
// 
//    }
// 
//    public Integer getId()
//    {
//       return id;
//    }
// 
//    public void setId(Integer id)
//    {
//       this.id = id;
//    }
// 
//    public String getName()
//    {
//       return name;
//    }
// 
//    public void setName(String name)
//    {
//       this.name = name;
//    }
// 
//    public Character getSexe()
//    {
//       return sexe;
//    }
// 
//    public void setSexe(Character sexe)
//    {
//       this.sexe = sexe;
//    }
// 
//    @Override
//    public int hashCode()
//    {
//       int hash = 0;
//       hash += (id != null ? id.hashCode() : 0);
//       return hash;
//    }
// 
//    @Override
//    public boolean equals(Object object)
//    {
//       if (!(object instanceof Player))
//       {
//          return false;
//       }
//       Player other = (Player) object;
//       if ((this.id == null && other.id != null)
//             || (this.id != null && !this.id.equals(other.id)))
//       {
//          return false;
//       }
//       else if (this.id == null && other.id == null)
//       {
//          if (this.name != null && other.name != null
//                && this.name.equals(other.name))
//             return true;
//       }
//       return false;
//    }
// 
//    @Override
//    public String toString()
//    {
//       return "Player@" + hashCode() + "[id = " + id + "; name = " + name
//             + "]";
//    }
// 
// }


// Path: app/tennistour-rest-api/src/main/java/com/mgreau/tennistour/core/rest/api/PlayerEndpoint.java
import com.mgreau.tennistour.core.entities.Player;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;

{
   @PersistenceContext(unitName = "tennistour")
   private EntityManager em;

   @POST
   @Consumes("application/json")
   public Response create(Player entity)
   {
      em.persist(entity);
      return Response.created(UriBuilder.fromResource(PlayerEndpoint.class).path(String.valueOf(entity.getId())).build()).build();
   }

   @DELETE
   @Path("/{id:[0-9][0-9]*}")
   public Response deleteById(@PathParam("id") Integer id)
   {
      Player entity = em.find(Player.class, id);
      if (entity == null)
      {
         return Response.status(Status.NOT_FOUND).build();
      }
      em.remove(entity);
      return Response.noContent().build();
   }

   @GET
   @Path("/{id:[0-9][0-9]*}")
   @Produces("application/json")
   public Response findById(@PathParam("id") Integer id)
   {
      TypedQuery<Player> findByIdQuery = em.createQuery("SELECT p FROM Player p WHERE p.id = :entityId", Player.class);