db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anas Mughal" <anasmug...@gmail.com>
Subject Re: Multiple Primary-keys - many-to-many (Again?)
Date Tue, 08 Apr 2008 10:26:06 GMT
Could you have a primary ID for the table.
That is how I went about avoiding composite primary keys.

Then, the many-to-many join would join with the primary ID instead of a
composite key.

Would that work for you?



On Mon, Apr 7, 2008 at 2:16 PM, Mario Caseiro <mario.caseiro@gmail.com>
wrote:

> Dear fellows,
>
> I have a big intuition that most of you guys should have some point in the
> past
> debated and answered this question already, but after days and days
> looking and
> seeking for some answer on the internet, I'm still without a solution.
>
> The question is:
>
>    How torque handles and deals with many-to-many relations?
>
>
> I'm aware of lots of comments about many-to-many in torque, things from:
> "You must have one primary-key and the others should be unique instead of
> primary"
>
> to thins like:
> "It's perfectly possible have many-to-many relations like:
>
> <table name="personCommittee">
> <column
>    name="IdComite"
>    required="true"
>    primaryKey="true"
>    type="INTEGER"/>
> <column
>    name="IdPerson"
>    required="true"
>    primaryKey="true"
>    type="INTEGER"/>
> </table>
>
> "
>
> I understand the point of "Primary keys" in "Design considerations" of the
> project web-site. (For every table, you should create a primary key which
> has no
> meaning in real life.)
>
> But there's a lot of cases that you really NEED or WANT to user multiple
> PK's.
>
>
> Like in this case that I'm stucked, I really need a many-to-many
> relationship,
> there's no way of workarounds or changeing tables structures.
>
>
> What should I do? Accept the ridiculous argueing that Hibernate is better
> because it have many-to-many relationship support?
>
>
> 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.
>
>
> What you guys could say me about multiple PK's in torque, what's wrong on
> this
> mapping and what would be the dificulties of implementing in Torque
> many-to-many
> relations since it already works for retrieving objects with multiple
> PK's?
>
>
>
> ps: Just for records, the mapping above genarates wrong SQL CREATE TABLE
> Syntax,
> since the default on genarator for primaryKey is add and "AUTO_INCREMENT"
> statement,
> if you set those columns autoIncrement="false" than it generates right DDL
> for that
> table.
>
>
>
>
> Thanx in advance
>
>
> Mario Caseiro
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>


-- 
Anas Mughal

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message