Hi Bill,

I add your new test cases to CVS. I made some minor
modifications.
Curious, all tests work like designed - test attached, check it out
please.

> If you comment out the two testMtoNSeparate_XX methods and run the
> junit test with testMtoNTogether, the resulting FISH table is:
you add two new fishs --> 2

> If you comment out testMtoNTogether, and run the junit test with the
> two testMtoNSeparate_XX methods, the resulting FISH table is:
you add two new fishs per test case --> 4

Did I overlook something?

regards,
Armin

----- Original Message -----
From: "Bill Lear" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 2:37 AM
Subject: Please Help! Still having problem with simplified
ManyToManyTest


> I have had no success, still, in getting the behavior I need for
> unique columns in OJB.  I have narrowed down the problem of unique
> columns to the code attached below my sig. --- a modification of the
> ManyToManyTest.
>
> If you comment out the two testMtoNSeparate_XX methods and run the
> junit test with testMtoNTogether, the resulting FISH table is:
>
> % echo 'select * from FISH;' | mysql ojb
>
> foodId  name    calories        typeOfWater
> 1       trout   52              fresh water
> 2       tuna    242             salt
>
> If you comment out testMtoNTogether, and run the junit test with the
> two testMtoNSeparate_XX methods, the resulting FISH table is:
>
> % echo 'select * from FISH;' | mysql ojb
>
> foodId  name    calories        typeOfWater
> 1       trout   52              fresh water
> 2       tuna    242             salt
> 3       tuna    242             salt
> 4       trout   52              fresh water
>
> So, my question is: "How do I get the two testMtoNSeparate_XX methods
> run together to have the same result on the FISH table as the
> testMtoNTogether method run alone?"  I do not want to have duplicate
> entries in the FISH table.  I have tried modifying the schema and
> repository_junit.xml to mark the FISH 'name' column as unique, as a
> primary key, non-nullable, etc., etc., to no avail.
>
> Since I have already spent a few days looking at the code and poring
> over the documentation and e-mail archives, if I can't find an answer
> to this within a day, I will have to report back to our organization
> that we will not be able to use OJB, which is a shame, as it looks to
> have great promise.
>
> Could someone please, please tell me if this is possible?  If not, is
> there a planned "fix" for it, if it is indeed a shortcoming?  I could
> work around this for the meantime, but I will need this functionality
> fairly soon.
>
> Thank you very much.
>
>
> Bill
>
> ======= Modified ManyToManyTest case ======
>
>
> package org.apache.ojb.odmg;
>
> import java.util.List;
>
> import junit.framework.TestCase;
>
> import org.apache.ojb.broker.Fish;
> import org.apache.ojb.broker.PersistenceBrokerFactory;
> import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration;
> import
org.apache.ojb.broker.util.configuration.ConfigurationException;
> import org.odmg.Database;
> import org.odmg.Implementation;
> import org.odmg.Transaction;
>
> public class ManyToManyTest extends TestCase {
>     private String databaseName;
>
>     public ManyToManyTest(String name) {
>         super(name);
>     }
>
>     public void setUp() {
>         try {
>             databaseName =
>                     ((PersistenceBrokerConfiguration)
PersistenceBrokerFactory
>                     .getConfigurator()
>                     .getConfigurationFor(null))
>                     .getRepositoryFilename();
>         } catch (ConfigurationException e) {
>             databaseName = "repository.xml";
>         }
>     }
>
>     public void tearDown() {
>         databaseName = null;
>     }
>
>     private void store(Implementation odmg, Database db, ODMGGourmet
gourmet) {
>         try {
>             Transaction tx = odmg.newTransaction();
>             tx.begin();
>             db.makePersistent(gourmet);
>             tx.commit();
>         } catch (Throwable e) {
>             fail("ERROR: " + e.getMessage());
>         }
>     }
>
>     private Database getDB(Implementation odmg) {
>         Database db = odmg.newDatabase();
>         try {
>             db.open(databaseName, Database.OPEN_READ_WRITE);
>         } catch (Throwable t) {
>             return null;
>         }
>         return db;
>     }
>
>     public void testMtoNSeparate_I() {
>         ODMGGourmet paula = new ODMGGourmet("paula");
>         ODMGGourmet candy = new ODMGGourmet("candy");
>
>         Fish tuna = new Fish("tuna", 242, "salt");
>         Fish trout = new Fish("trout", 52, "fresh water");
>
>         paula.addFavoriteFood(trout);
>
>         candy.addFavoriteFood(tuna);
>
>         Implementation odmg = OJB.getInstance();
>         Database db = getDB(odmg);
>
>         store(odmg, db, paula);
>         store(odmg, db, candy);
>     }
>
>     public void testMtoNSeparate_II() {
>         ODMGGourmet james = new ODMGGourmet("james");
>         ODMGGourmet doris = new ODMGGourmet("doris");
>
>         Fish tuna = new Fish("tuna", 242, "salt");
>         Fish trout = new Fish("trout", 52, "fresh water");
>
>         james.addFavoriteFood(tuna);
>
>         doris.addFavoriteFood(tuna);
>         doris.addFavoriteFood(trout);
>
>         Implementation odmg = OJB.getInstance();
>         Database db = getDB(odmg);
>
>         store(odmg, db, james);
>         store(odmg, db, doris);
>     }
>
>     public void testMtoNTogether() {
>         Fish tuna = new Fish("tuna", 242, "salt");
>         Fish trout = new Fish("trout", 52, "fresh water");
>
>         ODMGGourmet paula = new ODMGGourmet("paula");
>         ODMGGourmet candy = new ODMGGourmet("candy");
>
>         paula.addFavoriteFood(trout);
>         candy.addFavoriteFood(tuna);
>
>         Implementation odmg = OJB.getInstance();
>         Database db = getDB(odmg);
>
>         store(odmg, db, paula);
>         store(odmg, db, candy);
>
>         ODMGGourmet james = new ODMGGourmet("james");
>         ODMGGourmet doris = new ODMGGourmet("doris");
>
>         james.addFavoriteFood(tuna);
>
>         doris.addFavoriteFood(tuna);
>         doris.addFavoriteFood(trout);
>
>         store(odmg, db, james);
>         store(odmg, db, doris);
>     }
> }
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>

Attachment: ManyToManyTest.java
Description: Binary data

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to