I did propose you a solution. Just you didn't try: the cvs version.
Also, please take a deeper look at Castor test case, and try to see if anything you missed. I think your scenario is already in tests and all tests are passing. If you think otherwise, update the existing test case, show your problem and send us the "diff -u". My latest new song: "Smooth for me, not for you Cvs version is no cure But, no more answer to you, Useless I see diff minus u'." (diff -u) :-) Thomas -----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, November 20, 2001 1:15 AM >To: [EMAIL PROTECTED] >Subject: Re: [castor-dev] nullpointerexception with null foreign key > >Hi, > >that's not the case. It's just that if the fk-field (organization_id) is >null, the code gives me a nullpointerexception. If the fk-field is not >null (i.e. it's a value that references the other table), the code works >perfectly. It's the function QueryResults.hasMore() that nullpointers. > >Hopefully i've made the problem clear now... any solutions? > >Thank you, >Michel > >On Mon, 19 Nov 2001, Thomas Yip wrote: > >> >> Foregin key can certainly be null or valid. >> >> Ok. I was confused by your word "invalid", and the double negativity in a >> sentence. >> Invalid fk for me means there is no such row with in the related table has >> the fk as its pk. >> >> >> Thomas >> >> >> -----Original Message----- >> >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >> >Sent: Monday, November 19, 2001 1:12 PM >> >To: [EMAIL PROTECTED] >> >Subject: Re: [castor-dev] nullpointerexception with null foreign key >> > >> >Hi, >> > >> >this means you can't have a foreign-key that may be null? Cause i don't >> >think that's something you want in a database... >> > >> >This bug isn't a known one, with a known work-around? >> > >> >Thanks! >> >Michel >> > >> >On Mon, 19 Nov 2001, Thomas Yip wrote: >> > >> >> >> >> I don't think Castor is happy to deal with invalid foreign-key. >> >> >> >> However, try the cvs. It has a fixed on some problems of default value, >> >> which may get you a little bit further. >> >> >> >> But, it probably won't solve your special "correct behavior" problem. >> >> >> >> >> >> >> >> Thomas >> >> >> >> -----Original Message----- >> >> >From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED]] >> >> >Sent: Monday, November 19, 2001 8:35 AM >> >> >To: [EMAIL PROTECTED] >> >> >Subject: [castor-dev] nullpointerexception with null foreign key >> >> > >> >> >Hi there, >> >> > >> >> >I've got a database (SapDB), with a column which is a foreign key that >> may >> >> >be null; the table definition looks like this: >> >> > >> >> >create table users ( >> >> > id integer not null, >> >> > organization_id integer, >> >> > primary key(id) >> >> > ) >> >> > >> >> >create table organisations ( >> >> > id integer not null, >> >> > primary key(id) >> >> > ) >> >> > >> >> >alter table users >> >> > add foreign key org(organization_id) >> >> > references organizations(id) >> >> > on delete restrict; >> >> > >> >> >When i try to retrieve a user without an organization_id from the >> >> >database, castor throws a nullpointerexception from the hasMore method >> of >> >> >the QueryResults object with this stacktrace (only part shown): >> >> > >> >> >java.lang.NullPointerException >> >> > at java.lang.reflect.Method.invoke(Native Method) >> >> > at >> >> >org.exolab.castor.persist.FieldMolder.setValue(FieldMolder.java:307) >> >> > at >> >> >org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:674) >> >> > at >> org.exolab.castor.persist.LockEngine.load(LockEngine.java:361) >> >> > at >> >> >> >org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:5 >> >> 45) >> >> > at >> >> >org.exolab.castor.persist.QueryResults.fetch(QueryResults.java:229) >> >> > at >> >> >> >org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryIm >> >> pl.java:573) >> >> > at >> >> >> >org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryIm >> >> pl.java:556) >> >> > at nl.dysk.db.DatabaseObject.getVector(Unknown Source) >> >> > at nl.dysk.db.User.getVector(Unknown Source) >> >> > at java.lang.reflect.Method.invoke(Native Method) >> >> > >> >> > >> >> >However, when i try to retrieve a user that does have a valid >> >> >organization_id, no exception is thrown and everything works fine. >> >> > >> >> >I don't want to set the organization_id to not null, because that's not >> a >> >> >correct behaviour for my application. >> >> > >> >> >Does anyone have a solution to this problem? >> >> > >> >> >Thanks! >> >> > >> >> >Michel >> >> > >> >> >----------------------------------------------------------- >> >> >If you wish to unsubscribe from this mailing, send mail to >> >> >[EMAIL PROTECTED] with a subject of: >> >> > unsubscribe castor-dev >> >> > >> >> >> >> ----------------------------------------------------------- >> >> If you wish to unsubscribe from this mailing, send mail to >> >> [EMAIL PROTECTED] with a subject of: >> >> unsubscribe castor-dev >> >> >> > >> >----------------------------------------------------------- >> >If you wish to unsubscribe from this mailing, send mail to >> >[EMAIL PROTECTED] with a subject of: >> > unsubscribe castor-dev >> > >> >> ----------------------------------------------------------- >> If you wish to unsubscribe from this mailing, send mail to >> [EMAIL PROTECTED] with a subject of: >> unsubscribe castor-dev >> > >----------------------------------------------------------- >If you wish to unsubscribe from this mailing, send mail to >[EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev