Examples of CataloguePersistant


Examples of org.objectweb.speedo.pobjects.inheritance.ejboo2.CataloguePersistant

    final int NB_ARTICLE = 6;
    final int CATLAOGUE_SIZE = 3;
    final int MARCHE_SIZE = 2;
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    CataloguePersistant cat = null;
    int nbCat = 0;
    MarchePersistantImpl mar= null;
    int nbMar = 0;
    ArticlePersistantImpl a;
    for(int idArt=0; idArt<NB_ARTICLE; idArt++) {
      if ((idArt / CATLAOGUE_SIZE) == nbCat) {
        cat = new CataloguePersistantImpl(nbCat);
        pm.makePersistent(cat);
        nbCat ++;
      }
      if ((idArt / MARCHE_SIZE) == nbMar) {
        mar = new MarchePersistantImpl(nbMar);
        pm.makePersistent(mar);
        nbMar ++;
      }
      if ((idArt % 2) == 0) { //pair
        a = new ServicePersistantImpl(idArt);
        a.setNom("article_service_" + idArt);
      } else { //impair
        a = new MaterielPersistantImpl(idArt);
        a.setNom("article_materiel_" + idArt);
      }
      pm.makePersistent(a);
      a.setCatalogue(cat);
      mar.getArticles().add(a);
    }
    pm.currentTransaction().commit();

    a = null;
    cat = null;
    mar = null;
    pm.evictAll();

    pm.currentTransaction().begin();
    Extent extent = pm.getExtent(CataloguePersistantImpl.class, true);
    Iterator it = extent.iterator();
    ArrayList errors = new ArrayList();
    while(it.hasNext()) {
      cat = (CataloguePersistantImpl) it.next();
      logger.log(BasicLevel.DEBUG, "Catalogue " + cat.getId());
      Collection arts = cat.getArticles();
      Iterator articles = arts.iterator();
      while(articles.hasNext()) {
        a = (ArticlePersistantImpl) articles.next();
        logger.log(BasicLevel.DEBUG, "\tArticle " + a.getId());
        Collection mars = a.getMarches();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.