[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.tools.emf] [Teneo] Possible inconsistency using IdBags
|
Hello Martin,
I have encountered a problem concerning lists in my application. After
extensive debugging I have found out that this problem is connected with the
use of IdBags.
I use Eclipse 3.4, Teneo 1.0.1 and Hibernate 3.3.1 (also tested with 3.2.6)
The problem is the following:
When adding objects to a list, one part of the logic first makes
list.clear() and then adds all the newly submitted objects. The newly
submitted objects could possibly partly contain the once removed in
list.clear().
This is no problem unless the list being modified is the one having the last
rows in the database table! In this case only the new objects get added to
the list. The ones removed and then readded do not get persisted to the
database again. They are visible to the GUI (model), however, but only until
the application restarts.
The situation as an example:
Object Library has a unique ordered non-containment list referencing object
Book (Books are contained in object Publisher).
In the database there is a table Library _ Books with three columns:
Library id | Book id | ID
To start the following ids are in the table:
1|11|1
1|12|2
1|13|3
2|11|4
2|13|5
- I edit the list for the Library with id 2 in the GUI. I want to add a Book
reference with id 12.
- The logic makes list.clear() and thus removes all the Book references (11
and 13) for the Library with id 2.
- Then it adds the Book references 11, 12 and 13
- The transaction gets committed.
- The Model (EObjects) shows the following two lists:
1{11, 12, 13}
2{11, 12, 13}
- In the database I have the following:
1|11|1
1|12|2
1|13|3
2|12|4
- The expected result in the database would be
1|11|1
1|12|2
1|13|3
2|11|4
2|12|5
2|13|6
I'm able to resolve this behaviour by setting the
PersistenceOptions.MAP_ALL_LISTS_AS_IDBAG to false and recreate the
database. But I think it might be important to know about the impact of this
problem when using IdBags as it (for me) unexpectedly removed entries from
the database.
Greetings
Bjoern