No, there's no possibility for doing that. Why do you need it? :)
I would like to cache some entity beans that their state changed once in a very long time.
why do I need them to be held by the container?
I think you can just cache them. They will automatically become detached, you can reatach them with em.merge(entity)
I suggest you take a look at the Hibernate Entity Manager and Hibernate Annotations reference manuals
I'm not sure what you mean with "cache"...
If you want to make sure that they're up-to-date just call em.refresh(...) on the entities.
I suspect something like JBoss cache. Hibernate allows you to do query caching which might be of use here.
lets say i've a codes table(code/value columns) of 200 cities
and I would like to cache this table because it's a constant table and I wouldn't like to read from the db everytime..
i've Cities Enitity bean , do you think that if I'll query all the list and put it in some static hashtable it won't effect the EJB container preformance?
Yes, I think you are right, you do want to cache that list. But why build your own caching solution when there are lots out there already:
If you use JBoss EJB3/Hibernate
or the JBossCache stuff which is intergrated into Seam (probably in CVS)
those caches seem to complicated for my needs
I just need to cache 200 entity beans and retrieve some of them once in a while..(I never changed their content)
what do you think?would you use the Jboss cache for that?
whcih one? the tree cache of any other?