[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    Weird things with anonymous attributes an Indexes
From:       Sylvain juge <syl20j () gmail ! com>
Date:       2004-10-29 6:20:54
Message-ID: 7d9bebd7041028232069c52def () mail ! gmail ! com
[Download RAW message or body]

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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic