Thanks, Axel. I'll let you know about any progress I make ...

Werner

On Sun, 08 Aug 2004 08:25:28 +0200, Axel Mueller wrote:

>
>Werner,
>
>Werner Guttmann wrote:
>
>>Axel,
>>
>>On Sat, 07 Aug 2004 09:18:47 +0200, Axel Mueller wrote:
>>
>>  
>>
>>>Werner,
>>>
>>>Thanks for your reply! From your post I conclude that there is no 
>>>obvious mistake I made.
>>>    
>>>
>>Well, actually, this is not the case. Whilst I have not spotted any mistakes so far, 
>>it could equally be that there is ... hence my desire to 'replay' your 
>>scenario. Speaking of which, could be you please post your Java classes as well ?
>>  
>>
>So there is still hope the Castor rocks but the user doesn't ;-)
>Below are the classes (straight forward I would think). You can run the 
>Junit test class TestcaseFactoryTest in order to replay the test.
>
>----------------------------------------------------------------------------------------------
>package com.ibm.rfid.testcontroller;
>
>import org.apache.commons.logging.Log;
>import org.apache.commons.logging.LogFactory;
>import org.exolab.castor.jdo.Database;
>
>/**
> * @author Axel Mueller
> */
>public abstract class PersistentObjectFactory {
>
>    private static Log logger = 
>LogFactory.getLog(PersistentObjectFactory.class);
>
>    protected ClassLoader classLoader = null;
>
>    protected Database db = null;
>
>    protected boolean useExternalTransaction = false;
>
>
>    public PersistentObjectFactory(ClassLoader classLoader) {
>        this.classLoader = classLoader;
>    }
>
>    public void setDatabase(Database db) {
>        this.db = db;
>        useExternalTransaction = true;
>        logger.debug("Using external transaction.");
>    }
>
>}
>
>----------------------------------------------------------------------------------------------
>
>package com.ibm.rfid.testcontroller.testcase;
>
>import java.util.Iterator;
>import java.util.Vector;
>
>import org.apache.commons.logging.Log;
>import org.apache.commons.logging.LogFactory;
>import org.exolab.castor.jdo.OQLQuery;
>import org.exolab.castor.jdo.QueryResults;
>
>import com.ibm.rfid.testcontroller.PersistenceException;
>import com.ibm.rfid.testcontroller.PersistenceUtil;
>import com.ibm.rfid.testcontroller.PersistentObjectFactory;
>import com.ibm.rfid.testcontroller.UrlObjectTreeProvider;
>
>/**
> * @author Axel Mueller
> */
>public class TestcaseFactory extends PersistentObjectFactory {
>
>  private static Log logger = LogFactory.getLog(TestcaseFactory.class);
>
>  public TestcaseFactory(ClassLoader classLoader) {
>    super(classLoader);
>  }
>
>  public Testcase getTestcase(String urlString) throws TestcaseException {
>    return this.getTestcaseFromUrl(urlString);
>  }
>
>    public Testcase getTestcaseFromDatabase(String urlString) throws 
>TestcaseException {
>        Testcase testcase = null;
>        try {
>            if (!useExternalTransaction) {
>                db = 
>PersistenceUtil.getDatabase(this.getClass().getClassLoader());
>                db.begin();
>            }
>            OQLQuery oql = db.getOQLQuery("SELECT tc FROM 
>com.ibm.rfid.testcontroller.testcase.Testcase tc WHERE source = $1");
>            oql.bind(urlString);
>            QueryResults results = oql.execute();
>            logger.debug("Number of testcases: " + results.size());
>            while(results.hasMore()) {
>                 testcase = (Testcase) results.next();
>                 logger.debug("Number of testcase variables: " + 
>testcase.getTestcaseVariables().size());
>                 Vector variables = testcase.getTestcaseVariables();
>                 for (Iterator iter = variables.iterator(); 
>iter.hasNext(); ) {
>                        TestcaseVariable variable = (TestcaseVariable) 
>iter.next();
>                        logger.debug (variable);
>                 }
>            }
>            results.close();
>            if (!useExternalTransaction) {
>                db.commit();
>            }
>        }
>        catch (Throwable t) {
>            throw new TestcaseException(t);
>        }
>        finally {
>            if (!useExternalTransaction) {
>                try {
>                    db.close();
>                }
>                catch (org.exolab.castor.jdo.PersistenceException e) {
>                    logger.error("Error closing database: ", e);
>                }
>            }
>        }
>        return testcase;
>    }
>
>----------------------------------------------------------------------------------------------
>
>package com.ibm.rfid.testcontroller.testcase;
>
>import junit.framework.Assert;
>import junit.framework.TestCase;
>
>/**
> * @author Axel Mueller
> */
>public class TestcaseFactoryTest extends TestCase {
>
>  /**
>   * Constructor for TestcaseTest.
>   * @param arg0
>   */
>  public TestcaseFactoryTest(String arg0) {
>    super(arg0);
>  }
>
>    public void testAll() throws Exception {
>        String url = "file:///c:/Program 
>Files/DeviceDeveloper5.6/workspace/SOMT_TestController/definitions/palettentest.xml";
>        TestcaseFactory factory = new 
>TestcaseFactory(this.getClass().getClassLoader());
>//        Testcase testcase = factory.getTestcaseFromUrl(url);
>//        Assert.assertNotNull(testcase);
>//
>//        factory.writeTestcaseToDatabase(testcase);
>       
>        Testcase testcase = factory.getTestcaseFromDatabase(url);
>        Assert.assertNotNull(testcase);
>        Assert.assertEquals(2, testcase.getTestcaseVariables().size());
>    }
>}
>
>----------------------------------------------------------------------------------------------
>
>package com.ibm.rfid.testcontroller.testcase;
>
>import java.util.Iterator;
>import java.util.Vector;
>
>import org.apache.commons.logging.Log;
>import org.apache.commons.logging.LogFactory;
>import org.exolab.castor.jdo.TimeStampable;
>
>import com.ibm.rfid.testcontroller.PersistenceException;
>import com.ibm.rfid.testcontroller.TestRun;
>
>/**
> * @author Axel Mueller
> */
>public class Testcase implements TimeStampable {
>
>  private static Log logger = LogFactory.getLog(Testcase.class);
>
>  private Integer id;
>  private String source;
>    private String description;
>  private long timeStamp;
>
>  //
>  // Begin Castor managed relations
>  //
>
>  private Vector testcaseVariables;
>  private Vector testRuns;
>
>  /**
>   * @return
>   */
>  public Vector getTestcaseVariables() {
>    return this.testcaseVariables;
>  }
>
>  /**
>   * @param vector
>   */
>  public void setTestcaseVariables(Vector testcaseVariables) {
>    this.testcaseVariables = testcaseVariables;
>    if (testcaseVariables != null) {
>      Iterator itTestcaseVariables = this.testcaseVariables.iterator();
>      while (itTestcaseVariables.hasNext()) {
>        TestcaseVariable testcaseVariable = (TestcaseVariable) 
>itTestcaseVariables.next();
>        testcaseVariable.setTestcase(this);
>      }
>    }
>  }
>
>  public Vector getTestRuns() {
>    return this.testRuns;
>  }
>
>  /**
>   * @param vector
>   */
>  public void setTestRuns(Vector testRuns) {
>    this.testRuns = testRuns;
>    Iterator itTestRuns = this.testRuns.iterator();
>    while (itTestRuns.hasNext()) {
>      TestRun testRun = (TestRun) itTestRuns.next();
>      testRun.setTestcase(this);
>    }
>  }
>
>  public TestRun createTestRun() throws PersistenceException {
>    TestRun testRun = new TestRun();
>    testRun.setTestcase(this);
>    if (this.testRuns == null) {
>      this.testRuns = new Vector();
>    }
>    this.testRuns.add(testRun);
>    return testRun;
>  }
>
>  //
>  // End Castor managed relations
>  //
>
>  /**
>   * @return
>   */
>  public Integer getId() {
>    return this.id;
>  }
>
>  /**
>   * @param i
>   */
>  public void setId(Integer id) {
>    this.id = id;
>  }
>
>    /**
>     * @return
>     */
>    public String getSource() {
>        return source;
>    }
>
>    /**
>     * @param string
>     */
>    public void setSource(String string) {
>        source = string;
>    }
>
>  /**
>   * @return
>   */
>  public String getDescription() {
>    return description;
>  }
>
>  /**
>   * @param string
>   */
>  public void setDescription(String string) {
>    description = string;
>  }
>
>  /* (non-Javadoc)
>   * @see org.exolab.castor.jdo.TimeStampable#jdoSetTimeStamp(long)
>   */
>  public void jdoSetTimeStamp(long timeStamp) {
>    this.timeStamp = timeStamp;
>  }
>
>  /* (non-Javadoc)
>   * @see org.exolab.castor.jdo.TimeStampable#jdoGetTimeStamp()
>   */
>  public long jdoGetTimeStamp() {
>    return this.timeStamp;
>  }
>
>    public String toString() {
>        return " [ID] " + id + " [SOURCE] " + source + " [DESCRIPTION] " 
>+ description;
>    }
>
>}
>
>----------------------------------------------------------------------------------------------
>
>package com.ibm.rfid.testcontroller.testcase;
>
>import org.exolab.castor.jdo.TimeStampable;
>
>
>/**
> * @author Axel Mueller
> */
>public class TestcaseVariable implements TimeStampable {
>
>    private Integer id;
>    private int testcaseId;
>    private String label;
>    private String description;
>    private long timeStamp;
>
>   
>
>    //
>    // Begin Castor managed relations
>    //
>  private Testcase testcase;
>    private ValueRange valueRange;
> 
>    /**
>     * @return
>     */
>    public Testcase getTestcase() {
>        return testcase;
>    }
>
>    /**
>     * @param testcase
>     */
>    public void setTestcase(Testcase testcase) {
>        this.testcase = testcase;
>    }
> 
>    /**
>     * @return
>     */
>    public ValueRange getValueRange() {
>        return this.valueRange;
>    }
>
>    /**
>     * @param vector
>     */
>    public void setValueRange(ValueRange valueRange) {
>        this.valueRange = valueRange;
>        valueRange.setTestcaseVariable(this);
>    }
> 
>    //
>    // End Castor managed relations
>    //
>
>    /**
>     * @return
>     */
>    public int getId() {
>        return this.id.intValue();
>    }
>
>    /**
>     * @param i
>     */
>    public void setId(int id) {
>        this.id = new Integer(id);
>    }
>
>    /**
>     * @return
>     */
>    public int getTestcaseId() {
>        return testcaseId;
>    }
>
>    /**
>     * @param i
>     */
>    public void setTestcaseId(int testcaseId) {
>        this.testcaseId = testcaseId;
>    }
>
>    /**
>     * @return
>     */
>    public String getLabel() {
>        return this.label;
>    }
>
>    /**
>     * @param string
>     */
>    public void setLabel(String label) {
>        this.label = label;
>    }
>
>    /**
>     * @return
>     */
>    public String getDescription() {
>        return this.description;
>    }
>
>    /**
>     * @param string
>     */
>    public void setDescription(String description) {
>        this.description = description;
>    }
>
>    public String toString() {
>            return
>                    " [ID] "
>                + id
>                + " [LABEL]"
>                + label
>                + " [DESCRIPTION] "
>                + description;
>        }
>
>    /* (non-Javadoc)
>     * @see org.exolab.castor.jdo.TimeStampable#jdoSetTimeStamp(long)
>     */
>    public void jdoSetTimeStamp(long timeStamp) {
>        this.timeStamp = timeStamp;
>    }
>
>    /* (non-Javadoc)
>     * @see org.exolab.castor.jdo.TimeStampable#jdoGetTimeStamp()
>     */
>    public long jdoGetTimeStamp() {
>        return this.timeStamp;
>    }
>}
>
>I would be happy if you could provide some hint to solve this problem :-)
>
>Axel
>
>
>
>>  
>>
>>>Isn't this 1:n relation thing a very basic feature for any O/R mapping 
>>>tool? 
>>>    
>>>
>>Yes, it is, and it might as well turn out that the mistake is with 'you' ... 
>>configuration-wise or something else.
>>
>>  
>>
>>>The only O/R tools I used myself are JBoss EJB 2.0 CMR and Object 
>>>Relation Bridge.
>>>However, I consider Castor a mature tool in this area ...
>>>    
>>>
>>So would I, to be honest, despite some minor deficiencies.
>>
>>  
>>
>>>and would expect 
>>>problems rather on the user side than on the tool side. I choose Castor 
>>>for this project since I need XML binding as well as O/R mapping.
>>>
>>>The statements needed to replay the case:
>>>
>>>CREATE TABLE `testcase` (
>>> `id` int(10) unsigned NOT NULL default '0',
>>> `source` varchar(255) default NULL,
>>> `description` varchar(255) default NULL,
>>> PRIMARY KEY  (`id`)
>>>) TYPE=MyISAM;
>>>
>>>#
>>># Dumping data for table `testcase`
>>>#
>>>
>>>INSERT INTO `testcase` VALUES (1, 'file:///c:/Program 
>>>Files/DeviceDeveloper5.6/workspace/SOMT_TestController/definitions/palettentest.xml',
>>> 
>>>    
>>>
>>'Einfluss der Geschwindigkeit des Palettendurchgangs');
>>  
>>
>>>CREATE TABLE `testcase_variable` (
>>> `id` int(10) unsigned NOT NULL default '0',
>>> `testcase_id` int(10) unsigned NOT NULL default '0',
>>> `label` varchar(20) default NULL,
>>> `description` varchar(255) default NULL,
>>> PRIMARY KEY  (`id`),
>>> KEY `testcase_variable_FKIndex1` (`testcase_id`)
>>>) TYPE=MyISAM;
>>>
>>>#
>>># Dumping data for table `testcase_variable`
>>>#
>>>
>>>INSERT INTO `testcase_variable` VALUES (1, 1, 'Geschwindigkeit', 
>>>'Palettengeschwindigkeit');
>>>INSERT INTO `testcase_variable` VALUES (2, 1, 'Versuch', 'Versuch');
>>>   
>>>
>>>
>>>About iteration:  I forgot to mention it in my original post but I was 
>>>surprised to see that results.size() is 2 but only ONE iteration is 
>>>performed using a similar code snipped like below.
>>>After digging around I turned caching off yesterday already (prior my 
>>>post) but the behaviour was still the same.
>>>Anyway - below is the snippet's output you asked for:
>>>
>>>
>>>2004-08-07 09:01:55,366 DEBUG [main] engine.KeyGeneratorRegistry 
>>>(KeyGeneratorRegistry.java:114) - Key generator MAX has been 
>>>instantiated, parameters: {}
>>>2004-08-07 09:01:55,496 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1221) - Creating class: 
>>>com.ibm.rfid.testcontroller.testcase.Testcase using SQL: INSERT INTO 
>>>testcase (id,source,description) VALUES (?,?,?)
>>>2004-08-07 09:01:55,496 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1229) - Removing class: 
>>>com.ibm.rfid.testcontroller.testcase.Testcase using SQL: DELETE FROM 
>>>testcase WHERE id=?
>>>2004-08-07 09:01:55,496 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1262) - Updating class: 
>>>com.ibm.rfid.testcontroller.testcase.Testcase using SQL: UPDATE testcase 
>>>SET source=?,description=? WHERE id=? AND source=? AND description=?
>>>2004-08-07 09:01:55,506 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1336) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.Testcase using SQL: SELECT 
>>>testcase_variable.id,testcase.source,testcase.description FROM testcase 
>>>LEFT OUTER JOIN testcase_variable ON 
>>>testcase.id=testcase_variable.testcase_id WHERE testcase.id=?
>>>2004-08-07 09:01:55,576 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1221) - Creating class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: INSERT 
>>>INTO testcase_variable (id,testcase_id,label,description) VALUES (?,?,?,?)
>>>2004-08-07 09:01:55,576 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1229) - Removing class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: DELETE 
>>>    
>>>
>>>FROM testcase_variable WHERE id=?
>>  
>>
>>>2004-08-07 09:01:55,576 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1262) - Updating class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: UPDATE 
>>>testcase_variable SET testcase_id=?,label=?,description=? WHERE id=? AND 
>>>testcase_id=? AND label=? AND description=?
>>>2004-08-07 09:01:55,576 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1336) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: SELECT 
>>>testcase_variable.testcase_id,variable_value_range.id,testcase_variable.label,testcase_variable.description
>>> 
>>>    
>>>
>>>FROM testcase_variable LEFT OUTER JOIN variable_value_range ON 
>>  
>>
>>>testcase_variable.id=variable_value_range.id WHERE testcase_variable.id=?
>>>2004-08-07 09:01:55,576 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1221) - Creating class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: INSERT INTO 
>>>variable_value_range 
>>>(id,testcase_variable_id,minValue,maxValue,increment,unit) VALUES 
>>>(?,?,?,?,?,?)
>>>2004-08-07 09:01:55,586 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1229) - Removing class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: DELETE FROM 
>>>variable_value_range WHERE id=?
>>>2004-08-07 09:01:55,586 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1262) - Updating class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: UPDATE 
>>>variable_value_range SET 
>>>testcase_variable_id=?,minValue=?,maxValue=?,increment=?,unit=? WHERE 
>>>id=? AND testcase_variable_id=? AND minValue=? AND maxValue=? AND 
>>>increment=? AND unit=?
>>>2004-08-07 09:01:55,586 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1336) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: SELECT 
>>>
variable_value_range.testcase_variable_id,variable_value_range.minValue,variable_value_range.maxValue,variable_value_range.increment,variable
>>>    
>>>
>>_value_range.unit 
>>>FROM variable_value_range WHERE variable_value_range.id=?
>>  
>>
>>>2004-08-07 09:01:55,626 DEBUG [main] cache.CacheFactory 
>>>(CacheFactory.java:128) - Creating cache instance for type none
>>>2004-08-07 09:01:55,636 DEBUG [main] cache.CacheFactory 
>>>(CacheFactory.java:128) - Creating cache instance for type none
>>>2004-08-07 09:01:55,636 DEBUG [main] cache.CacheFactory 
>>>(CacheFactory.java:128) - Creating cache instance for type none
>>>2004-08-07 09:01:55,837 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:384) - Create SQL: SELECT 
>>>testcase.id,testcase_variable.id,testcase.source,testcase.description 
>>>    
>>>
>>>FROM testcase LEFT OUTER JOIN testcase_variable ON 
>>  
>>
>>>testcase.id=testcase_variable.testcase_id WHERE (testcase.source = ?)
>>>2004-08-07 09:01:57,099 DEBUG [main] engine.SQLEngine$SQLQuery 
>>>(SQLEngine.java:1699) - jdo.executing
>>>2004-08-07 09:01:57,289 DEBUG [main] testcase.TestcaseFactory 
>>>(TestcaseFactory.java:58) - Number of testcases: 2
>>>2004-08-07 09:01:57,309 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>Removing cache entry for key com.ibm.rfid.testcontroller.testcase.Testcase/1
>>>2004-08-07 09:01:57,339 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>Removing cache entry for key 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1
>>>2004-08-07 09:01:57,339 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1020) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: SELECT 
>>>testcase_variable.testcase_id,variable_value_range.id,testcase_variable.label,testcase_variable.description
>>> 
>>>    
>>>
>>>FROM testcase_variable LEFT OUTER JOIN variable_value_range ON 
>>  
>>
>>>testcase_variable.id=variable_value_range.id WHERE testcase_variable.id=?
>>>2004-08-07 09:01:57,369 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>Removing cache entry for key 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1
>>>2004-08-07 09:01:57,369 DEBUG [main] engine.SQLEngine 
>>>(SQLEngine.java:1020) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: SELECT 
>>>
variable_value_range.testcase_variable_id,variable_value_range.minValue,variable_value_range.maxValue,variable_value_range.increment,variable
>>>    
>>>
>>_value_range.unit 
>>>FROM variable_value_range WHERE variable_value_range.id=?
>>  
>>
>>>2004-08-07 09:01:57,399 DEBUG [main] persist.LockEngine 
>>>(LockEngine.java:370) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange with id: 1
>>>2004-08-07 09:01:57,399 DEBUG [main] persist.LockEngine 
>>>(LockEngine.java:370) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable with id: 1
>>>2004-08-07 09:01:57,409 DEBUG [main] persist.LockEngine 
>>>(LockEngine.java:370) - Loading class: 
>>>com.ibm.rfid.testcontroller.testcase.Testcase with id: 1
>>>2004-08-07 09:01:57,409 DEBUG [main] testcase.TestcaseFactory 
>>>(TestcaseFactory.java:61) - Number of testcase variables: 1
>>>2004-08-07 09:01:57,409 DEBUG [main] testcase.TestcaseFactory 
>>>(TestcaseFactory.java:65) -  [ID] 1 [LABEL]Geschwindigkeit [DESCRIPTION] 
>>>Palettengeschwindigkeit
>>>2004-08-07 09:01:57,419 DEBUG [main] persist.ObjectLock 
>>>(ObjectLock.java:821) - Release 
>>>com.ibm.rfid.testcontroller.testcase.Testcase/1/0 R/- by 
>>>[EMAIL PROTECTED]
>>>2004-08-07 09:01:57,419 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>Creating cache entry for key 
>>>com.ibm.rfid.testcontroller.testcase.Testcase/1 with value 
>>>com.ibm.rfid.testcontroller.testcase.Testcase/1/0 -/-
>>>2004-08-07 09:01:57,419 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>Disposing object com.ibm.rfid.testcontroller.testcase.Testcase/1/0 -/-
>>>2004-08-07 09:01:57,419 DEBUG [main] persist.ObjectLock 
>>>(ObjectLock.java:821) - Release 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 R/- by 
>>>[EMAIL PROTECTED]
>>>2004-08-07 09:01:57,429 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>Creating cache entry for key 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1 with value 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 -/-
>>>2004-08-07 09:01:57,429 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>Disposing object 
>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 -/-
>>>2004-08-07 09:01:57,429 DEBUG [main] persist.ObjectLock 
>>>(ObjectLock.java:821) - Release 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 R/- by 
>>>[EMAIL PROTECTED]
>>>2004-08-07 09:01:57,429 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>Creating cache entry for key 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1 with value 
>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 -/-
>>>2004-08-07 09:01:57,439 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>Disposing object com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 -/-
>>>
>>>Still hoping to solve the problem ;-)
>>>
>>>Axel
>>>
>>>
>>>Werner Guttmann wrote:
>>>
>>>    
>>>
>>>>Axel,
>>>>
>>>>can you please post the DDL you used to create the testcase and testcase_variable 
>>>>tables. I'd like to be able to replay what you've experienced.
>>>>
>>>>Just out of curiosity, if you iterated through all testCaseVariables, do you at 
>>>>least get all of them returned ? Iow, if you changed 
>>>>
>>>>OQLQuery oql = db.getOQLQuery("SELECT tc FROM 
>>>>com.ibm.rfid.testcontroller.testcase.Testcase tc WHERE source = $1");
>>>>oql.bind(urlString);
>>>>QueryResults results = oql.execute();
>>>>logger.debug("Number of testcases: " + results.size());
>>>>while(results.hasMore()) {
>>>>  testcase = (Testcase) results.next();
>>>>  logger.debug("Number of testcase variables: " + 
>>>> testcase.getTestcaseVariables().size());
>>>>  Vector variables = testcase.getTestCaseVariables();
>>>>  for (Iterator iter = variables.iterator(); iter.hasNext(); ) {
>>>>     TestCaseVariable variable = (TestCaseVariable) iter.next();
>>>>     logger.debug (variable);
>>>>  }
>>>>}
>>>>
>>>>what's the output ?
>>>>
>>>>Werner
>>>>
>>>>On Fri, 06 Aug 2004 18:20:54 +0200, Axel Mueller wrote:
>>>>
>>>> 
>>>>
>>>>      
>>>>
>>>>>Hi,
>>>>>
>>>>>For two tables "testcase" (class Testcase) and "testcase_variable" 
>>>>>(class TestcaseVariable) I have defined a 1:n relation and perform a 
>>>>>OQLQuery on the "1" side of that relation (which is Testcase).
>>>>>Table "testcase" contains only one row whereas the table 
>>>>>"testcase_variables" contains 2 rows whose foreign key matches the 
>>>>>primary key of the row in "testcase":
>>>>>
>>>>>mysql> select id from testcase;
>>>>>+----+
>>>>>| id |
>>>>>+----+
>>>>>|  1 |
>>>>>+----+
>>>>>1 row in set (0.00 sec)
>>>>>
>>>>>mysql> select * from testcase_variable;
>>>>>+----+-------------+-----------------+-------------------------+
>>>>>| id | testcase_id | label           | description             |
>>>>>+----+-------------+-----------------+-------------------------+
>>>>>|  1 |           1 | Geschwindigkeit | Palettengeschwindigkeit |
>>>>>|  2 |           1 | Versuch         | Versuch                 |
>>>>>+----+-------------+-----------------+-------------------------+
>>>>>
>>>>>I would expect the query below to return ONE Testcase object and the 
>>>>>testcase object to contain TWO TestcaseVariable objects.
>>>>>Actually  results.size() returns 2 and 
>>>>>testcase.getTestcaseVariables().size() returns 1 - exactly the opposite 
>>>>>of what I would have expected.
>>>>>What am I doing wrong??? I found some examples of 1:n relations but I'm 
>>>>>doing the query the same way the do using the same kind of mapping to 
>>>>>express the 1:n relation.
>>>>>
>>>>>
>>>>>          OQLQuery oql = db.getOQLQuery("SELECT tc FROM 
>>>>>com.ibm.rfid.testcontroller.testcase.Testcase tc WHERE source = $1");
>>>>>          oql.bind(urlString);
>>>>>          QueryResults results = oql.execute();
>>>>>          logger.debug("Number of testcases: " + results.size());
>>>>>          while(results.hasMore()) {
>>>>>              testcase = (Testcase) results.next();
>>>>>              logger.debug("Number of testcase variables: " + 
>>>>>testcase.getTestcaseVariables().size());
>>>>>          }
>>>>>
>>>>>
>>>>>The relevant section of the mapping descriptor looks like this:
>>>>>
>>>>>  <class name="com.ibm.rfid.testcontroller.testcase.Testcase" 
>>>>>identity="id" key-generator="MAX">
>>>>>      <cache-type type="none"/>
>>>>>      <map-to table="testcase" xml="testcase"/>
>>>>>      <field name="testcaseVariables" 
>>>>>type="com.ibm.rfid.testcontroller.testcase.TestcaseVariable" 
>>>>>collection="vector">
>>>>>          <sql many-key="testcase_id"/>
>>>>>          <bind-xml name="testcase-variable" node="element"/>
>>>>>      </field>
>>>>>      <!-- field name="testRuns" 
>>>>>type="com.ibm.rfid.testcontroller.TestRun" collection="vector">
>>>>>          <sql many-key="testcase_id"/>
>>>>>          <bind-xml name="testcase-run" node="element"/>
>>>>>      </field -->
>>>>>      <field name="id">
>>>>>          <sql name="id"/>
>>>>>          <bind-xml name="id" node="attribute"/>
>>>>>      </field>
>>>>>      <field name="source">
>>>>>          <sql name="source"/>
>>>>>          <bind-xml name="source" node="attribute"/>
>>>>>      </field>
>>>>>      <field name="description">
>>>>>          <sql name="description"/>
>>>>>          <bind-xml name="description" node="attribute"/>
>>>>>      </field>
>>>>>  </class>
>>>>>
>>>>>  <class name="com.ibm.rfid.testcontroller.testcase.TestcaseVariable" 
>>>>>identity="id" key-generator="MAX">
>>>>>      <cache-type type="none"/>
>>>>>      <map-to table="testcase_variable" xml="testcase-variable"/>
>>>>>      <field name="testcase" 
>>>>>type="com.ibm.rfid.testcontroller.testcase.Testcase">
>>>>>          <sql name="testcase_id" />
>>>>>          <bind-xml name="testcase-id" node="element" reference="true"/>
>>>>>      </field>
>>>>>      <field name="valueRange" 
>>>>>type="com.ibm.rfid.testcontroller.testcase.ValueRange">
>>>>>          <bind-xml name="value-range" node="element"/>
>>>>>      </field>
>>>>>      <field name="id">
>>>>>          <sql name="id"/>
>>>>>          <bind-xml name="id" node="attribute"/>
>>>>>      </field>
>>>>>      <field name="label">
>>>>>          <sql name="label"/>
>>>>>          <bind-xml name="label" node="attribute"/>
>>>>>      </field>
>>>>>      <field name="description">
>>>>>          <sql name="description"/>
>>>>>          <bind-xml name="description" node="attribute"/>
>>>>>      </field>
>>>>>  </class>
>>>>>
>>>>>
>>>>>
>>>>>Below is the logging of the query code snipped above:
>>>>>
>>>>>
>>>>>2004-08-06 17:38:30,989 DEBUG [main] engine.SQLEngine 
>>>>>(SQLEngine.java:384) - Create SQL: SELECT 
>>>>>testcase.id,testcase_variable.id,testcase.source,testcase.description 
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>>FROM testcase LEFT OUTER JOIN testcase_variable ON 
>>>> 
>>>>
>>>>      
>>>>
>>>>>testcase.id=testcase_variable.testcase_id WHERE (testcase.source = ?)
>>>>>2004-08-06 17:38:31,380 DEBUG [main] engine.SQLEngine$SQLQuery 
>>>>>(SQLEngine.java:1699) - jdo.executing
>>>>>2004-08-06 17:38:31,410 DEBUG [main] testcase.TestcaseFactory 
>>>>>(TestcaseFactory.java:57) - Number of testcases: 2
>>>>>2004-08-06 17:38:31,420 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>>>Removing cache entry for key com.ibm.rfid.testcontroller.testcase.Testcase/1
>>>>>2004-08-06 17:38:31,450 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>>>Removing cache entry for key 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1
>>>>>2004-08-06 17:38:31,450 DEBUG [main] engine.SQLEngine 
>>>>>(SQLEngine.java:1020) - Loading class: 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable using SQL: SELECT 
>>>>>testcase_variable.testcase_id,variable_value_range.id,testcase_variable.label,testcase_variable.description
>>>>> 
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>>FROM testcase_variable LEFT OUTER JOIN variable_value_range ON 
>>>> 
>>>>
>>>>      
>>>>
>>>>>testcase_variable.id=variable_value_range.id WHERE testcase_variable.id=?
>>>>>2004-08-06 17:38:31,460 DEBUG [main] cache.NoCache (NoCache.java:122) - 
>>>>>Removing cache entry for key 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1
>>>>>2004-08-06 17:38:31,460 DEBUG [main] engine.SQLEngine 
>>>>>(SQLEngine.java:1020) - Loading class: 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange using SQL: SELECT 
>>>>>
>>>>>        
>>>>>
>>
variable_value_range.testcase_variable_id,variable_value_range.minValue,variable_value_range.maxValue,variable_value_range.increment,variable
>>  
>>
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>_value_range.unit 
>>>>>FROM variable_value_range WHERE variable_value_range.id=?
>>>> 
>>>>
>>>>      
>>>>
>>>>>2004-08-06 17:38:31,470 DEBUG [main] persist.LockEngine 
>>>>>(LockEngine.java:370) - Loading class: 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange with id: 1
>>>>>2004-08-06 17:38:31,470 DEBUG [main] persist.LockEngine 
>>>>>(LockEngine.java:370) - Loading class: 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable with id: 1
>>>>>2004-08-06 17:38:31,470 DEBUG [main] persist.LockEngine 
>>>>>(LockEngine.java:370) - Loading class: 
>>>>>com.ibm.rfid.testcontroller.testcase.Testcase with id: 1
>>>>>2004-08-06 17:38:31,490 DEBUG [main] testcase.TestcaseFactory 
>>>>>(TestcaseFactory.java:60) - Number of testcase variables: 1
>>>>>2004-08-06 17:38:31,500 DEBUG [main] persist.ObjectLock 
>>>>>(ObjectLock.java:821) - Release 
>>>>>com.ibm.rfid.testcontroller.testcase.Testcase/1/0 R/- by 
>>>>>[EMAIL PROTECTED]
>>>>>2004-08-06 17:38:31,500 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>>>Creating cache entry for key 
>>>>>com.ibm.rfid.testcontroller.testcase.Testcase/1 with value 
>>>>>com.ibm.rfid.testcontroller.testcase.Testcase/1/0 -/-
>>>>>2004-08-06 17:38:31,510 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>>>Disposing object com.ibm.rfid.testcontroller.testcase.Testcase/1/0 -/-
>>>>>2004-08-06 17:38:31,510 DEBUG [main] persist.ObjectLock 
>>>>>(ObjectLock.java:821) - Release 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 R/- by 
>>>>>[EMAIL PROTECTED]
>>>>>2004-08-06 17:38:31,510 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>>>Creating cache entry for key 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1 with value 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 -/-
>>>>>2004-08-06 17:38:31,520 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>>>Disposing object 
>>>>>com.ibm.rfid.testcontroller.testcase.TestcaseVariable/1/1 -/-
>>>>>2004-08-06 17:38:31,520 DEBUG [main] persist.ObjectLock 
>>>>>(ObjectLock.java:821) - Release 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 R/- by 
>>>>>[EMAIL PROTECTED]
>>>>>2004-08-06 17:38:31,520 DEBUG [main] cache.NoCache (NoCache.java:93) - 
>>>>>Creating cache entry for key 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1 with value 
>>>>>com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 -/-
>>>>>2004-08-06 17:38:31,520 DEBUG [main] cache.NoCache (NoCache.java:157) - 
>>>>>Disposing object com.ibm.rfid.testcontroller.testcase.ValueRange/1/2 -/-
>>>>>
>>>>>
>>>>>
>>>>>----------------------------------------------------------- 
>>>>>If you wish to unsubscribe from this mailing, send mail to
>>>>>[EMAIL PROTECTED] with a subject of:
>>>>>      unsubscribe castor-user
>>>>>
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>
>>>>----------------------------------------------------------- 
>>>>If you wish to unsubscribe from this mailing, send mail to
>>>>[EMAIL PROTECTED] with a subject of:
>>>>       unsubscribe castor-user
>>>>
>>>>
>>>> 
>>>>
>>>>      
>>>>
>>>
>>>----------------------------------------------------------- 
>>>If you wish to unsubscribe from this mailing, send mail to
>>>[EMAIL PROTECTED] with a subject of:
>>>       unsubscribe castor-user
>>>
>>>    
>>>
>>
>>
>>
>>----------------------------------------------------------- 
>>If you wish to unsubscribe from this mailing, send mail to
>>[EMAIL PROTECTED] with a subject of:
>>        unsubscribe castor-user
>>
>>
>>  
>>
>
>
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-user
>



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to