Is it possible to have Hibernate persistent classes written with EJB3 annotations used from within EJB2 session beans?
Sure, just do it.
The persistent classes will require the EJB3 jar file, but the session beans will require the EJB2 jar file.
How do I get around the mismatch of EJB versions? Is it enough to put the EJB3 jar after the EJB2 one? I assume Hibernate only needs the definitions of the annotations from the EJB3 jar.
The 2 will not clash, since EJB3 will be abckward compatible with EJB2
Also, along similar lines, if my session beans return any instances of the annotated classes to a client, then that client also needs the EJB3 jar in its classpath. Is there any way to get around that?
You'll be able to use the description descriptor instead, but I don't really consider the ejb3-ann.jar too much a requirement in the client side, it will be small.