I have a unique instance where I'd really like to use Hibernate 3.1's "not-found=ignore" attribute in my NHibernate app. It sounds like a mere convenience thing, and we could do some things w/ triggers to make things happy, but this would make life SO much easier.
Optionally, if anybody could suggest an alternative here, I'd be thrilled to have a suggestion or two.
We're writing some software to send bulk e-mails. We're collecting from a variety of sources, a list of "black-out" email addresses. People we've cut off of our distribution lists, people who have opted out, bounced e-mails, etc. Because of the nature of our system, an e-mail associated with a user is not GUARANTEED to be uniqe.
We're doing a query . . . a very complex query to decide who to send a bulk e-mail to.
It works fine. We have the HQL built and everything. Now, we'd like to take this bulk e-mail list and check to see if our users' e-mail addresses are in this blackout list . . . so I add to my HQL query the following sub-query . . .
Code:
where user.Email not in (select blackoutList.Email from BlackoutEmailInfo as blackoutList)
or some such syntax. It times out. We turn off the timeout, and seriously . . . two and a half minutes with no return from the database. Otherwise, the query is quick as lightning.
What I'd LIKE to do is set this blackout info table up so it has a relationship to the user. Then I can do something in the query like
Code:
where user.emailBlackoutInfo is null
for when the user's email isn't on the blackout list.
I TRIED to do the following mapping . . .
Code:
<many-to-one name="emailBlackoutInfo" column="Email" class="BlackoutEmailInfo" update="false" insert="false" outer-join="true"/> <!-- no, there's no property-ref, 'cause the e-mail is the primary key. -->
And it seemed to work 'til I ran it through unit tests, and lo and behold . . . the 'Email' column always has a value which MAY OR MAY NOT be in the blackout list. So of course, I get the dreaded 'no object with the specified primary key' or something like that error.
Thus the wish for the not-found=ignore attribute.
Any suggestions would be greatly appreciated.
Thanks in advance.
-Falken