Thought a dump may help. I looked at the source to try to figure it out, and gather it's trying to construct the SuCityState, finds it is not there in the first sql query, and creates the second one to try and fails.
Somehow it should know that the thing being null is fine and not bother with a query attempt.
I am wondering, what internally tells hibernate the difference between a null value and a yet-to-be populated value?
Code:
2003-09-05 14:19:00,750 INFO [STDOUT] Hibernate: select suairpor0_.airportcode
as airportcode0_, sucity1_.citycode as citycode1_, sucityco2_.cityCode as cityCo
de2_, sucountr3_.countryCode as countryCode3_, sucityst4_.cityCode as cityCode4_
, sustate5_.statecode as statecode5_, suairpor0_.airportname as airportn2_0_, su
airpor0_.airportcitycode as airportc3_0_, suairpor0_.airportsearable as airports
4_0_, suairpor0_.airportinbufferzone as airporti5_0_, suairpor0_.airportlatitude
as airportl6_0_, suairpor0_.airportlongitude as airportl7_0_, sucity1_.cityName
as cityName1_, sucityco2_.countrycode as countryc2_2_, sucountr3_.countryCode3
as countryC2_3_, sucountr3_.countryName as countryN3_3_, sucountr3_.countryNumbe
r as countryN4_3_, sucityst4_.statecode as statecode4_, sustate5_.statename as s
tatename5_ from su_airport suairpor0_ left outer join su_city sucity1_ on suairp
or0_.airportcitycode=sucity1_.citycode left outer join su_citycountry sucityco2_
on suairpor0_.airportcitycode=sucityco2_.cityCode left outer join su_country su
countr3_ on sucityco2_.countrycode=sucountr3_.countryCode left outer join su_cit
ystate sucityst4_ on suairpor0_.airportcitycode=sucityst4_.cityCode left outer j
oin su_state sustate5_ on sucityst4_.statecode=sustate5_.statecode order by sua
irpor0_.airportcode asc
2003-09-05 14:19:04,956 INFO [STDOUT] Hibernate: select sustate1_.statecode as
statecode0_, sustate1_.statename as statename0_, sucityst0_.cityCode as cityCode
1_, sucityst0_.statecode as statecode1_ from su_citystate sucityst0_ left outer
join su_state sustate1_ on sucityst0_.statecode=sustate1_.statecode where sucity
st0_.cityCode=?
2003-09-05 14:19:05,056 FATAL [SULOGGER.main] :VBSF Airport Cache
Exception text -> No row with the given identifier exists: AAE, of class: com.st
udentuniverse.farefilter.persistent.SuCityState
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exist
s: AAE, of class: com.studentuniverse.farefilter.persistent.SuCityState
at net.sf.hibernate.impl.SessionImpl.throwObjectNotFound(SessionImpl.jav
a:1678)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1717)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.j
ava:62)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1
959)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:196)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)