db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject Re: Multiple Primary-keys - many-to-many (Again?)
Date Tue, 08 Apr 2008 19:41:29 GMT
>>> <table name="personCommittee">
>>> <column
>>>    name="IdComite"
>>>    required="true"
>>>    primaryKey="true"
>>>    type="INTEGER"/>
>>> <column
>>>    name="IdPerson"
>>>    required="true"
>>>    primaryKey="true"
>>>    type="INTEGER"/>
>>> </table>

>>> In that mapping above, I can make it work, but only for retrieving
>>> objects.
>>> It works perfectly hidrating the objects, no problem at all.
>>> But I can not create a new object, by the time of .save() method, It
>>> raises an
>>> exception of "Criteria has nothing to insert", it's something saying that
>>> the
>>> criteria was empty, and so on nothing is inserted/saved into database.

There is nothing wrong with your mapping, except that you should use 
idMethod="none" for tables where you do not want or torque does not 
support auto-generated primary keys (as in your mapping; auto-generation 
of primary keys would not make sense). This is what you do with 
auto-increment=none, but settinbg the defaultIdMethod is preferred 
(because more db-independent).

> Does torque really don't suport multiple-primary keys or there's some hidden
> way for getting them work?

I have mappings like yours working for me so composite primary keys are 
definitely supported by torque. To work out why you run into problems, I'd 
need some more information:

- what database are you using ?
- Could you provide a simple code sample where you try to save a 
PersonCommittee object ?


To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message