Mantis - Resin
Viewing Issue Advanced Details
2586 minor always 04-09-08 09:16 04-09-08 10:52
closed 3.0.26  
none 3.1.6  
0002586: Amber: multiple @OneToMany
(rep by Charles Lyons)

I have a model containing two objects:

Organisation (a company to which individuals may belong)
User (a user inside an organisation)

To make matters slightly more complicated, an organisation may "own"
another organisation, for example, a company which is part of a holding
group. Therefore:

A User has many-to-one correspondence with an Organisation [an Organisation
may have many users but a user has only one organisation]

An Organisation has many-to-one correspondence with a parent Organisation
[an Organisation may have only one "owner" but may own many]

The two classes:

public class Organisation {

   private int id;

   private Organisation owner; // the owner of this organisation, if any -
IS being initialised properly

   private Collection<Organisation> ownedOrganisations; // all the
organisations this one owns

   private Collection<User> users; // all the users associated with this

   // getters/setters

public class User {

   private int id;

   private Organisation organisation; // the organisation to which this
user belongs - this IS being initialised properly

   // getters/setters

Now it seems Amber cannot populate both @OneToMany collections in the
Organisation. If I remove one or the other then it will populate the
remaining one as expected. If I leave both in, only the first one (as it
appears listed in the source code) is populated and the second Collection
remains null (i.e. is not even initialised like most other collections are,
to empty collections). I see no reason why both should not be populated
according to the relations I specify. For reference, the relevant fields of
the database are:

Table organisations =================== id INT UNSIGNED PRIMARY KEY
AUTO_INCREMENT ownerid INT UNSIGNED --- reference to an
for an owning organisation

Table users =========== id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT orgid
INT UNSIGNED -- reference to an for the org to which this
user belongs

I've tested this on the 31st March snapshot. Is this a bug? Any idea when
the next snapshot will be released which might contain a fix?

04-09-08 10:52   

Amber docs are at [^]