plug in a 2nd level cache the same way you would for regular hibernate. There is a default hibernate.properties in the ejb3.deployer/META-INF directory. If you want to override these values, just create a hibernate.properties within your foo.ejb3/META-INF or foo.ear/META-INF packaged deployment.
Bill, thanks for your answer. I do have a working separate hibernate.properties in my ejb3-archive but I don't know how to enable caching for classes within this file. I have read the FAQ on hibernate.org and the relevant chapters in Hibernate in Action and found the following statement:
In FAQ (http://www.hibernate.org/117.html#A32)
Is the second-level cache enabled by default?
No entities or collections will be cached in the second-level cache unless you supply <cache> elements in the mapping files or <class-cache> and/or <collection-cache> elements in hibernate.cfg.xml, even when EHCache or some other cache provider is configured.
As the mapping files are generated in your implementation this seems to be a problem. Is there a simple workaround I haven't seen?