Originally posted by Andy Hahn:
I dont think you need to define for each region, that is optional according to the ehcache documentation.
OK, if the docs say they are optional, then they are optional.
But really I guess then back to the original question.
The question for me now resides with are you still in the same Session when you requery for the parent? And if so, that means the cached parent object you get back might be from either the first level cache or the second level cache. If it is in the first level cache, I recall some sort of refresh(Object) type method in the Session that will tell Hibernate to ignore any instances in the Persistence Context, and go back to the database. Although if you added the child in the same session with the Parent object that is in the Persistence Context, then when you get it again from the Persistence Context, it should be the same with that new child. hmm.
If not in the same session, then it is prbably from the second level cache. So if it is the second level cache, I would ask what is the "stale" setting for that cache region, or the "stale" setting for all regions (What you would get not defining each region). When I say stale, I mean the setting that says when to refresh the cache, is it at every query, at a certain time period, or after the cache reaches a certain size.
But I will say this, most issues are in the configuration files.
Mark