Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002586 [Resin] minor always 04-09-08 09:16 04-09-08 10:52
Reporter ferg View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.0.26
Summary 0002586: Amber: multiple @OneToMany
Description (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:

@Entity
@Table(name="organisations")
public class Organisation {

   @Id
   @GeneratedValue
   private int id;

   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumn(name="ownerid")
   private Organisation owner; // the owner of this organisation, if any -
IS being initialised properly

   @OneToMany(mappedBy="owner",cascade=CascadeType.ALL)
   private Collection<Organisation> ownedOrganisations; // all the
organisations this one owns

   @OneToMany(mappedBy="organisation",cascade=CascadeType.ALL)
   private Collection<User> users; // all the users associated with this
organisation

   // getters/setters
}


@Entity
@Table(name="users")
public class User {

   @Id
   @GeneratedValue
   private int id;

   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumn(name="orgid")
   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 organisations.id
for an owning organisation

Table users =========== id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT orgid
INT UNSIGNED -- reference to an organisations.id 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?

Additional Information
Attached Files

- Relationships

- Notes
(0002951)
ferg
04-09-08 10:52

jpa/0j06

Amber docs are at http://caucho.com/resin/doc/amber.xtp [^]
 

- Issue History
Date Modified Username Field Change
04-09-08 09:16 ferg New Issue
04-09-08 10:52 ferg Note Added: 0002951
04-09-08 10:52 ferg Assigned To  => ferg
04-09-08 10:52 ferg Status new => closed
04-09-08 10:52 ferg Resolution open => fixed
04-09-08 10:52 ferg Fixed in Version  => 3.1.6


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
28 total queries executed.
25 unique queries executed.
Powered by Mantis Bugtracker