Package org.objectweb.speedo.pobjects.fetchgroup

Examples of org.objectweb.speedo.pobjects.fetchgroup.Country


   * test the definition of a fetch-group in the jdo file with a a.b.c field
   * <field name="a.b.c">
   */
  public void testRefreshReference() {
    logger.log(BasicLevel.DEBUG, "***************testRefreshReference*****************");
    Country country = new Country("it","Italie");
    Address address = new Address("Rue Spiaggi", "Milan", country);
    Person parent = new Person();
    parent.setName("Del Piero Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Del Piero Sophie", address, null, 14);
    Person child2 = new Person("Del Piero Mikael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      FetchPlan fp = pm.getFetchPlan();
      fp.clearGroups();
      fp.addGroup("detail").removeGroup("default");
      pm.currentTransaction().begin();
      logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
      pm.makePersistent(parent);
      Object id = pm.getObjectId(parent);
      pm.currentTransaction().commit();
      logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
   
      pm.currentTransaction().begin();
      //update the age and the address
      parent.setAge(99);
      Address newAddress = new Address("rue Ampere", "Rennes", new Country("bz", "Bretagne"));
      parent.setAddress(newAddress);
      pm.refresh(parent)
      pm.currentTransaction().commit();
      assertEquals(32, parent.getAge());
      assertEquals(address.getCity(), parent.getAddress().getCity());
View Full Code Here


   * test the definition of a fetch-group in the jdo file with a a#element.b field
   * <field name="a#element.b">
   */
  public void testRefreshArrayElement() {
    logger.log(BasicLevel.DEBUG, "************testRefreshArrayElement**************");
    Country country = new Country("be","Belgique");
    Address address = new Address("Rue Anvers", "Bruges", country);
    Person parent = new Person();
    parent.setName("Dermuck Joel");
    parent.setAge(32);
    parent.setAddress(address);
    int ageChild1 = 14;
    int ageChil2 = 11;
    Person child1 = new Person("Dermuck Sophie", address, null, ageChild1);
    Person child2 = new Person("Dermuck Mikael", address, null, ageChil2);
    int totalAgeChildren = 14 + 11;
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail+children-names").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try{
      pm.currentTransaction().begin();
      //update the first child age and address
      Person p = (Person) parent.getChildren().iterator().next();
      p.setAge(2000);
      Address newAddress = new Address("Rue Refresh", "Moon", new Country("m", "mars"));
      p.setAddress(newAddress);
      pm.refresh(parent);
   
      int totalAgeRefreshed = 0;
      Iterator it = parent.getChildren().iterator();
View Full Code Here

   * test the definition of a fetch-group in the jdo file with a fetch-group attribute in a field
   * <field name="a" fetch-group="fg"/>
   */
  public void testRefreshFetchGroupField() {
    logger.log(BasicLevel.DEBUG, "************testRefreshFetchGroupField**************");
    Country country = new Country("us","Etats-Unis");
    Address address = new Address("Rue Enclif", "San Diego", country);
    Person parent = new Person();
    parent.setName("Smith Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Smith Sofia", address, null, 14);
    Person child2 = new Person("Smith Michael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail+children-list").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try{
      pm.currentTransaction().begin();
      //  update the first child age and address
      Person p = (Person) parent.getChildren().iterator().next();
      p.setAge(2000);
      Address newAddress = new Address("Rue Far", "Moon", new Country("n", "neptune"));
      p.setAddress(newAddress);
      pm.refresh(parent);
   
      pm.currentTransaction().commit();
      Person ch = (Person) parent.getChildren().iterator().next();
View Full Code Here

   * for recursive reference
   * <field name="a" depth="X"/>
   */
  public void testRefreshRecursiveDepth() {
    logger.log(BasicLevel.DEBUG, "************testRefreshRecursiveDepth**************");
    Country country = new Country("sp","Espagne");
    Address address = new Address("Rue Rio", "Santander", country);
    Person parent = new Person();
    parent.setName("Casillas Joel");
    parent.setAge(63);
    parent.setAddress(address);
    Person child1 = new Person("Casillas Sofia", address, null, 30);
    Person child2 = new Person("Casillas Michael", address, null, 40);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
    Person child11 = new Person("Casillas Maria", address, null, 14);
    Person child21 = new Person("Casillas Juan", address, null, 11);
    Set children1 = new HashSet();
    children1.add(child11);
    Set children2 = new HashSet();
    children2.add(child21);
    child1.setChildren(children1);
    child2.setChildren(children2);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detailChildren").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try{
      Address a = new Address("Rue So", "Moon", new Country("k", "Krypton"));
   
      pm.currentTransaction().begin();
      Person p = (Person) parent.getChildren().iterator().next();
      p.setAge(2000);
      p.setAddress(a);
View Full Code Here

   * test the definition of a fetch-group in the jdo file with a depth attribute defined twice for a field
   * <field name="a" depth="X"/>
   */
  public void testRefreshDoubleDepth() {
    logger.log(BasicLevel.DEBUG, "************testRefreshDoubleDepth**************");
    Country country = new Country("bl","Belarus");
    Address address = new Address("Rue Kaloc", "Minsk", country);
    Person parent = new Person();
    parent.setName("Castuk Joel");
    parent.setAge(63);
    parent.setAddress(address);
    Person child1 = new Person("Castuk Sofia", address, null, 40);
    Person child2 = new Person("Castuk Michael", address, null, 40);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
    Person child11 = new Person("Castuk Maria", address, null, 11);
    Person child21 = new Person("Castuk Juan", address, null, 11);
    Set children1 = new HashSet();
    children1.add(child11);
    Set children2 = new HashSet();
    children2.add(child21);
    child1.setChildren(children1);
    child2.setChildren(children2);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detailChildren2").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try{
      pm.currentTransaction().begin();
      Address a = new Address("Rue Away", "Moon", new Country("pl", "Pluton"));
      Person p = (Person) parent.getChildren().iterator().next();
      p.setAge(2000);
      p.setAddress(a);
      Person pc = (Person) p.getChildren().iterator().next();
      pc.setAge(3000);
View Full Code Here

   * <field name="a" depth="X"/>
   */
  public void testRefreshDoubleDepthUnlimited() {
    logger.log(BasicLevel.DEBUG, "************testRefreshDoubleDepthUnlimited**************");
   
    Country country = new Country("p","Portugal");
    Address address = new Address("Rue Christiano", "Lisbonne", country);
    Person grandParent = new Person();
    grandParent.setName("Simoes Joel");
    grandParent.setAge(90);
    grandParent.setAddress(address);
    Person parent1 = new Person("Simoes Sofia", address, null, 70);
    Person parent2 = new Person("Simoes Michael", address, null, 70);
    Set parent = new HashSet();
    parent.add(parent1);
    parent.add(parent2);
    grandParent.setChildren(parent);
    Person child1 = new Person("Simoes Maria", address, null, 40);
    Person child2 = new Person("Simoes Juan", address, null, 40);
    Set children1 = new HashSet();
    children1.add(child1);
    Set children2 = new HashSet();
    children2.add(child2);
    parent1.setChildren(children1);
    parent2.setChildren(children2);
    Person grandChild1 = new Person("Simoes Leia", address, null, 10);
    Person grandChild2 = new Person("Simoes Carlos", address, null, 10);
    Set grandChildren1 = new HashSet();
    grandChildren1.add(grandChild1);
    Set grandChildren2 = new HashSet();
    grandChildren2.add(grandChild2);
    child1.setChildren(grandChildren1);
    child2.setChildren(grandChildren2);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detailChildren3").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + grandParent.toString());
    pm.makePersistent(grandParent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
   
    try {
      pm.currentTransaction().begin();
      Address a = new Address("Rue From", "Moon", new Country("sl", "Solarus"));
      Person pParent = (Person) grandParent.getChildren().iterator().next();
      pParent.setAge(2000);
      pParent.setAddress(a);
      Person pChild = (Person) pParent.getChildren().iterator().next();
      pChild.setAge(3000);
View Full Code Here

  /**
   * Test the loading with the "all" fetch group : all the fields of the class are loaded
   */
  public void testLoadingAll() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingAll*****************");
    Country country = new Country("it","Italie");
    Address address = new Address("Rue Spiaggi", "Milan", country);
    Person parent = new Person();
    parent.setName("Del Piero Joel");
    parent.setAge(32);
    parent.setAddress(address);
View Full Code Here

  /**
   * Test the loading with the "default" fetch group
   */
  public void testLoadingDefault() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingDefault*****************");
    Country country = new Country("fr","France");
    Address address = new Address("rue Anatole France", "Tours", country);
    Person parent = new Person();
    parent.setName("Bordes Joel");
    parent.setAge(32);
    parent.setAddress(address);
View Full Code Here

  /**
   * Test the loading with the "none" fetch group : only the pk is loaded
   */
  public void testLoadingNone() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingNone*****************");
    Country country = new Country("uk","Royaume-Uni");
    Address address = new Address("Sharrow Street", "Luton", country);
    Person parent = new Person();
    parent.setName("None Joel");
    parent.setAge(32);
    parent.setAddress(address);
View Full Code Here

  /**
   * Test the loading with the "values" fetch group : only the values field of the default are loaded
   */
  public void testLoadingValues() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingValues*****************");
    Country country = new Country("gr","Grece");
    Address address = new Address("Feta", "Athenes", country);
    Person parent = new Person();
    parent.setName("Kapic Joel");
    parent.setAge(32);
    parent.setAddress(address);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.fetchgroup.Country

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.