Re: [Jaxor-devel] Re: Associating Lists
Brought to you by:
mrettig
From: Carl F. <car...@gm...> - 2004-08-10 19:54:15
|
I am kinda stuck. I thought about creating a wrapper for ArrayList but that seemed... smelly. I really want to go the ListChangeListener route but am a bit stuck on the how... Any pointers on what to look at to get an idea of how to do this? On Mon, 9 Aug 2004 08:26:24 -0700 (PDT), Michael Rettig <mik...@ya...> wrote: > This seems like a sensible approach. Though, I don't > think it should need to implement EntityInterface. If > it does, then that really smells. > > You may want to create a new listener interface for a > list (i.e. ListChangeListener) to listen for additions > and removals. This would allow you to set/unset the > keys properly. > > Mike > > --- Carl Fyffe <car...@gm...> wrote: > > > Is the answer to have EntityListAdapterBase > > implement ValueChangeListener? > > > > I am afraid that if that is the answer, then it will > > also have to > > implement EntityInterface. Is that the case? > > > > On Mon, 9 Aug 2004 01:24:43 -0400, Carl Fyffe > > <car...@gm...> wrote: > > > How do I watch the List to see if it changes? > > That seems to be what > > > needs to be done to fix > > testAddingAnEntityToAListAlreadySetOnEntity() > > > I keep thinking that a change to List.vm may fix > > the problem, but I > > > haven't figured out how. I took a swing and seem > > to have struck out. > > > Any pointers for my next time at bat? > > > > > > > > > > > > On Sun, 8 Aug 2004 12:14:11 -0400, Carl Fyffe > > <car...@gm...> wrote: > > > > Thank you! I will get right on them. I also have > > some news on the ManyToMany. > > > > > > > > ManyToMany does not work anything like > > OneToMany. Yes at the heart it > > > > is just two OneToMany's pointing in different > > directions, but they > > > > point in the wrong directions. > > > > > > > > This is REALLY what I want to have work: > > > > group.setUserList(members); > > > > > > > > But that means that UserList will have to know > > about GroupMember and I > > > > don't see anyway to make that happen without > > making a change to the > > > > DTD and thus the generated .java files. I am > > trying to avoid that if > > > > possible. > > > > > > > > Next, I tried this: > > > > GroupMemberEntity gme = new GroupMemberBase(); > > > > gme.setGroupEntity(group); > > > > gme.setUserList(members); > > > > > > > > But like I said earlier, the OneToMany's point > > in the wrong direction. > > > > User's don't have one GroupMember, they have > > lots. So if you have a > > > > user and you want to set a list of GroupMembers, > > that works, but we > > > > have a list of Users. This is the other thought > > that I have had: > > > > > > > > group.setUserList(members, > > GroupMemberEntity.class); > > > > > > > > Pass in some reference that would allow the > > setter to know what to > > > > link with. Again that would require a change in > > the DTD and I think > > > > the other way is cleaner so I would prefer to go > > with the other idea > > > > if I have to change the DTD. > > > > > > > > Can you give me a hint at which would be a > > better "interface" for the developer? > > > > > > > > I will start working on your tests and continue > > thinking about the above. > > > > > > > > On Sat, 7 Aug 2004 19:34:30 -0700 (PDT), Michael > > Rettig > > > > > > > > > > > > <mik...@ya...> wrote: > > > > > Carl, > > > > > > > > > > That was quick. I added a couple new failing > > tests. If > > > > > we have a list that is already set on on > > entity, > > > > > then we need to set the foreign fields for > > each entity > > > > > that is added to the list. Also, if we change > > the > > > > > value of the key on the source entity, then we > > need to > > > > > update the keys on the list entities. > > > > > > > > > > I checked in the tests. Do you want to take a > > stab at > > > > > them? > > > > > > > > > > --- Carl Fyffe <car...@gm...> wrote: > > > > > > > > > > > I have checked the code in for OneToMany. > > There are > > > > > > two issues that I > > > > > > am unhappy about. First, you must have an > > > > > > <entity-ref> in the .jaxor > > > > > > of the foreign object (see email.jaxor) and > > for > > > > > > setXXXXXList(list) to > > > > > > work. It throws a SQLValidationException > > and tells > > > > > > you that the > > > > > > column was expected to have a value, but for > > some > > > > > > reason this doesn't > > > > > > "smell" good. > > > > > > > > > > > > Second, I have added this method to > > > > > > ForeignFieldLazyLoader: > > > > > > > > > > > > private boolean isForeignKey(EntityRow > > > > > > targetEntity) { > > > > > > for(Iterator iterator = > > > > > > targetEntity.getForeignFields().iterator(); > > > > > > iterator.hasNext();) { > > > > > > ForeignFieldLazyLoader loader = > > > > > > (ForeignFieldLazyLoader) > > > > > > iterator.next(); > > > > > > if > > (loader.getResolver().isUnique()) > > > > > > return true; > > > > > > } > > > > > > return false; > > > > > > } > > > > > > > > > > > > The idea is to find out if the targetEntity > > is > > > > > > related to the > > > > > > sourceEntity. I have tested against > > ManyToManyTest > > > > > > and against my new > > > > > > OneToManyTest and all lights are green. > > This method > > > > > > works, and I > > > > > > don't know why. I was expecting to need to > > check > > > > > > directly against the > > > > > > sourceEntity as well, but apparently I > > don't. > > > > > > > > > > > > The concern is that it will set the list for > > the > > > > > > wrong foreign > > > > > > field... I am sorry if this seems un-smart, > > but it > > > > > > seems like magic > > > > > > to me :-) Can anyone come up with a test > > that will > > > > > > cause this method > > > > > > to return true, thus allowing a save to the > > wrong > > > > > > table? > > > > > > > > > > > > On Sat, 7 Aug 2004 14:49:55 -0700 (PDT), > > Michael > > > > > > Rettig > > > > > > <mik...@ya...> wrote: > > > > > > > Carl, > > > > > > > > > > > > > > You should have write permissions. I added > > you to > > > > > > the > > > > > > > project as a developer. > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://sourceforge.net/project/memberlist.php?group_id=59712 > > > > > > > > > > > > > > Did you checkout the project using ssh? > > > > > > > > > > > > > > http://sourceforge.net/cvs/?group_id=59712 > > > > > > > > > > > > > > Mike > > > > > > > > > > > > > > --- Carl Fyffe <car...@gm...> > > wrote: > > > > > > > > > > > > > > > Since a Many to Many is really just a > > One to > > > > > > Many on > > > > > > > > two sides, I > > > > > > > > thought I would solve the One to Many > > problem > > > > > > first. > > > > > > > > That is done. I > > > > > > > > would like to check the code in, but I > > don't > > > > > > have > > > > > > > > write permission in > > > > > > > > the repository. > > > > > > > > > > > > > > > > On Sat, 7 Aug 2004 10:08:14 -0700 (PDT), > > Michael > > > === message truncated === > > > > > __________________________________ > Do you Yahoo!? > New and Improved Yahoo! Mail - 100MB free storage! > http://promotions.yahoo.com/new_mail > |