Re: What is wrong with this code?
Re: What is wrong with this code?
- Subject: Re: What is wrong with this code?
- From: Kevin Windham <email@hidden>
- Date: Thu, 12 Apr 2007 16:26:42 -0500
Is there something about posting to the list that makes things
suddenly seem clearer or what. I looked over my model again, and
discovered that EOModeler had not included column names for the IDs
in the join table. I thought it did this automatically when choosing
the Join in Many-to-Many function. Anyway, I added the column names
and reran the SQL, cleaned and rebuilt and now it appears to work as
it should.
Sorry for the wasted bandwidth,
Kevin
On Apr 12, 2007, at 4:07 PM, Kevin Windham wrote:
I have a user class in my session class. I also have a club class.
I am trying to add a new club to my user and am using the following
code.
Session session = (Session)session();
EOEditingContext ec = session.defaultEditingContext();
Club club = new Club();
ec.insertObject(club);
club.setApproved(false);
club.setClubName(clubName);
club.setWebsite(clubWebsite);
session.user.addToClubs(club);
ec.saveChanges();
The code causes an exception at the addToClubs(club) line. I am
unsure as to why this is. I have used similar code before. My guess
is that it has something to do with the eomodel and the way many to
manys work versus one to manys. The other code I've written like
this before deals with one to many relationships. In this case, the
user-clubs is a many to many. From what I've read in the docs, WO
should be able to handle the linking table automatically, but it
doesn't seem to be working that way. Did I miss something, or does
this just not work this way?
Thanks,
Kevin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden