i'm quite a newbie using OJB, but I think that I found womething weird....

When using an index on two tables fields, it seems that if one of the
two fields is an anonymous field, the index is simply forgiven on
runtime.

Here is the working example :

----[AbstractRoom.java]----

/**
*
* --- Artificial PK ---
*
* @ojb.field   name="id"
*                              primarykey="true"
*              autoincrement="database"
*                              jdbc-type="INTEGER"
*/

abstract public class AbstractRoom implements StorableObject{

   /**
    * Room/Apt n�
    *
        * @ojb.field name="number"
        */
       protected int number;

...
}

----[Room.java]----

/**
* @ojb.class table="kdms_rooms"
*
* @ojb.index name="room_unique"
*            unique="true"
*            fields="number,apartment_id"
*/

public class Room extends AbstractRoom {

   /**
    * Apt id (FK automatically managed by OJB)
        * @ojb.field   name="apartment_id"
       *                               jdbc-type="INTEGER"
    * */
   private int apartment_id;

...
}

------------------ And now the one that doesn't work ---------------

----[AbstractRoom.java]----
unchanged

----[Room.java]----

/*
* @ojb.class table="kdms_rooms"
*
* @ojb.index name="room_unique"
*            unique="true"
*            fields="number,apartment_id"
*
* Apt id (FK automatically managed by OJB)
* @ojb.field   name="apartment_id"
*                              jdbc-type="INTEGER"
*/

public class Room extends AbstractRoom {
}

This version results in an error in my JUnit test cases, because index
seems to be ignored and duplicates are created when storing objects.
However MySQL table index is the same in both cases, that's why I
can't understand why is it possible to have such as duplicates...

Any help would be appreciated.
Sylvain.

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

Reply via email to