I came acrtoss the same problem and after doing a little research found
that it was due to it only having the two key in the table.  It may have
been the version of the tdk I have been working with, but anyway the
solution was, .add an addional arbitury field ( in my case I just added
an active field of booleen) set, and set the sequence type to none, this
is a bit of a kludge but it allowed me to get on with things.

-----Original Message-----
From: Bernardo Arlandis Mano [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 23 January 2003 5:19 AM
To: Turbine Users List
Subject: Re: Torque foreign key tables


Ryan Clifton wrote:

>So I've been using Torque for two days and have had to fix two major
bugs to get it to work for me.. either I'm doing things very wrong or
this framework has some serious issues.  
>
>Has anyone seen this?  Does anyone use a pure foreign key table
successfully?  If so, what am I doing wrong? 
>
>Here is what I found today:
>
>I have 3 tables, PARTNER, PERSON, and PARTNER_PERSON
>
>PARTNER_PERSON holds an m:n mapping between PARTNER and PERSON.  DDL:
>
>create table PARTNER_PERSON (
>       PARTNER_ID      NUMBER references PARTNER.id,
>       PERSON_ID       NUMBER references PERSON.id
>)
>
>I can use Torque to create Persons and Partners, but when I try to
create a PartnerPerson object to save a relationship, I get an error
stating:
>
>        at
com.win.core.testcase.TorqueTestCase.main(TorqueTestCase.java:32)
>rethrown as org.apache.torque.TorqueException: Database insert
attempted without
> anything specified to insert
>
>This is of course after having set the values within it.  Here is my
test code:
>
>         Partner partner = new Partner();
>        partner.setemail("[EMAIL PROTECTED]");
>        partner.setpName("xxx");
>        partner.setNew(true);
>        partner.save();
>
>        Person person1 = new Person();
>        person1.setfName("Ryan");
>        person1.setlName("Clifton");
>        person1.setNew(true);
>        person1.save();
>
>        PartnerPerson pu = new PartnerPerson();
>        //pu.setPartner(partner);
>        //pu.setPerson(person1);
>        pu.setpartnerId(partner.getID());
>        pu.setpersonId(person1.getID());
>        pu.setNew(true);
>        pu.save();
>
>I have tried setting the values in every combination that is possible
(not using ID, but using the objects for exampls).  I've tried setting
setNew(false).  I either get no error and no saved record or an error on
insert.
>
>I fixed the problem by editing
BasePartnerPersonPeer.java::buildCriteria(PartnerPerson obj)
>Here is the original:
>
>    /** Build a Criteria object from the data object for this peer */
>    public static Criteria buildCriteria( PartnerPerson obj )
>    {
>        Criteria criteria = new Criteria(DATABASE_NAME);
>
>        if (!obj.isNew())
>            criteria.add(PERSON_ID, obj.getpersonId());
>        if (!obj.isNew())
>            criteria.add(PARTNER_ID, obj.getpartnerId());
>        return criteria;
>    }
>
>After looking at some other BaseXXPeer classes, I noticed that they
always add something to a criteria.  In the above case, it's possible to
not add anything to the criteria.  So the simple fix was this:
>
>    /** Build a Criteria object from the data object for this peer */
>    public static Criteria buildCriteria( PartnerPerson obj )
>    {
>        Criteria criteria = new Criteria(DATABASE_NAME);
>
>        //if (!obj.isNew())
>            criteria.add(PERSON_ID, obj.getpersonId());
>        //if (!obj.isNew())
>            criteria.add(PARTNER_ID, obj.getpartnerId());
>        return criteria;
>    }
>
>
>
>Thanks!
>
>--
>To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>
>  
>
Take a look at how the fluxapp works. It uses that kind of relationship 
between some tables. Maybe you're getting something wrong.

-- 
Bernardo



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


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

Reply via email to