Package org.objectweb.speedo.pobjects.detach

Examples of org.objectweb.speedo.pobjects.detach.Player


        }
    }
  private void createPlayers(){
    Team t = new Team("Bordeaux",null,null);
    Collection players = new ArrayList();
    Player p1 = new Player("p1", t, 25);
    players.add(p1);
    Player p2 = new Player("p2", t, 32);
    players.add(p2);
    t.setPlayers(players);
    Coach c = new Coach("c1", 5, t);
    t.setCoach(c);
   
    Team t2 = new Team("Nantes", null, null);
    Collection players2 = new ArrayList();
    Player p3 = new Player("p3", t2, 25);
    players2.add(p3);
    Player p4 = new Player("p4", t2, 32);
    players2.add(p4);
    t2.setPlayers(players2);
    Coach c2 = new Coach("c2", 5, t2);
    t2.setCoach(c2);
   
View Full Code Here


   */
  public void testDetachCopy() {
    logger.log(BasicLevel.DEBUG, "***************testDetachCopy*****************");
    Team t = new Team("Bordeaux",null,null);
    Collection players = new ArrayList();
    Player p1 = new Player("p1", t, 25);
    players.add(p1);
    Player p2 = new Player("p2", t, 32);
    players.add(p2);
    t.setPlayers(players);
    Coach c = new Coach("c1", 5, t);
    t.setCoach(c);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the team " + t.toString());
    pm.makePersistent(t);
    pm.currentTransaction().commit();
   
    t = null;
    p1 = null;
    p2 = null;
    c = null;
   
    pm.evictAll();
    pm.close();
   
   
    pm = pmf.getPersistenceManager();
    Query query = pm.newQuery(Team.class, "players.contains(player) & player.age<12");
    query.declareVariables("Player player");
    Collection results = (Collection)query.execute();
    assertTrue("The result of the query should be empty.", results.isEmpty());
    query.closeAll();
   
    query = pm.newQuery(Team.class, "players.contains(player) & player.age>12");
    query.declareVariables("Player player");
    results = (Collection)query.execute();
    assertTrue("The result of the query shouldn't be empty.", !results.isEmpty());
    Team res = (Team) results.iterator().next();
    Collection cpl = res.getPlayers();
    Iterator itPlayer = cpl.iterator();
    while(itPlayer.hasNext()) {
      Player pl = (Player) itPlayer.next();
      assertTrue("The age of the player should be over 12. It is " + pl.getAge() + ".", pl.getAge()>12);
    }
    query.closeAll();
   
    query = pm.newQuery(Team.class, "town==\"Bordeaux\"");
    results = (Collection)query.execute();
View Full Code Here

  public void testDetachNonPersistentCopy() {
    logger.log(BasicLevel.DEBUG, "*************testDetachNonPersistentCopy*****************");
    Team t = new Team("Marseille",null,null);
    Coach c = new Coach("c2", 5, t);
    t.setCoach(c);
    Player p = new Player("p3", t, 25);
    t.addPlayer(p);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    //detach the team t while it is not persistent
    Team copyOfT = (Team) pm.detachCopy(t);
View Full Code Here

  public void testDetachPersistentNew() {
    logger.log(BasicLevel.DEBUG, "******************testDetachPersistentNew****************");
    Team t = new Team("Monaco",null,null);
    Coach c = new Coach("c3", 5, t);
    t.setCoach(c);
    Player p = new Player("p4", t, 25);
    t.addPlayer(p);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(c);
View Full Code Here

  public void testDetachPersistentDirty() {
    logger.log(BasicLevel.DEBUG, "******************testDetachPersistentDirty****************");
    Team t = new Team("Nantes",null,null);
    Coach c = new Coach("c4", 5, t);
    t.setCoach(c);
    Player p = new Player("p5", t, 28);
    t.addPlayer(p);
       
    PersistenceManager pm = pmf.getPersistenceManager();
    //make persistent
    pm.currentTransaction().begin();
View Full Code Here

  public void testDetachPersistentDeleted() {
    logger.log(BasicLevel.DEBUG, "******************testDetachPersistentDeleted****************");
    Team t = new Team("Paris",null, null);
    Coach c = new Coach("c5", 5, t);
    t.setCoach(c);
    Player p = new Player("p6", t, 28);
    t.addPlayer(p);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    //make persistent
    pm.currentTransaction().begin();
View Full Code Here

  public void testDetachPersistentDeletedCollection() {
    logger.log(BasicLevel.DEBUG, "******************testDetachPersistentDeletedCollection****************");
    Team t = new Team("Auxerre",null, null);
    Coach c = new Coach("c6", 10, t);
    t.setCoach(c);
    Player p = new Player("p7", t, 28);
    t.addPlayer(p);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    //make persistent
    pm.currentTransaction().begin();
View Full Code Here

   */
  public void testDetachNullReference() {
    logger.log(BasicLevel.DEBUG, "***************testDetachNullReference*****************");
    Team t = new Team("Niort",null,null);
    Collection players = new ArrayList();
    Player p1 = new Player("p8", t, 25);
    players.add(p1);
    Player p2 = new Player("p9", t, 32);
    players.add(p2);
    t.setPlayers(players);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
View Full Code Here

   */
  public void testVersion1() {
    logger.log(BasicLevel.DEBUG, "***************testVersion1*****************");
    Team t = new Team("T1",null,null);
    Collection players = new ArrayList();
    Player p1 = new Player("p1", t, 20);
    players.add(p1);
    Player p2 = new Player("p2", t, 30);
    players.add(p2);
    t.setPlayers(players);
    Coach c = new Coach("c1", 10, t);
    t.setCoach(c);
    PersistenceManager pm = pmf.getPersistenceManager();
View Full Code Here

   */
  public void testVersion2() {
    logger.log(BasicLevel.DEBUG, "***************testVersion2*****************");
    Team t = new Team("T2",null,null);
    Collection players = new ArrayList();
    Player p1 = new Player("p3", t, 20);
    players.add(p1);
    Player p2 = new Player("p4", t, 30);
    players.add(p2);
    t.setPlayers(players);
    Coach c = new Coach("c2", 10, t);
    t.setCoach(c);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(t);
    pm.currentTransaction().commit();
    //begin
    pm.currentTransaction().begin();
    //modify the coach
    t.getCoach().setExperience(99);
    Iterator it  = t.getPlayers().iterator();
    //modify the players
    while(it.hasNext()){
      Player p = (Player) it.next();
      p.setAge(99);
    }
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //commit
    pm.currentTransaction().commit();
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.detach.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.