Quote:
If you do not have hibernate-annotations in your classpath at runtime, it will be all good. The annotations will just be ignored by the VM, so the portability of your domain model is the wrong excuse: your domain model IS NOT BOUND to hibernate when you use annotations.
In case you want to move away from Hibernate, I actually find the annotation mode easier, you will know what is hibernate specific and replace it with your other provider specific annotations at the same place.
As far as the annotations go, i know that if you don't have the worker classes in the classpath to process them, annotations are ignored. However, the second thing you pointed out is you'll know what's Hibernate and what isn't, and that makes it easier to replace. Unfortunately, this assumes that
1) You are going to use annotations from your new provider.
and the big one:
2) You're going to, or you need to, recompile your domain model code in order to reuse it with the new provider.
I'm not sure where I stand on #2, but i know where my organization does: I shouldn't have to recompile my domain model (entity classes) to get it to work with a new ORM provider. With Hibernate's mapping via XML support, i can create a domain model jar, and then create a Hibernate-based DAO jar which maps said entities to tables.
This discussion has been making me think about what practices are good/bad (for me in any event). While I like annotations for some functionality, i think that the use of implementation specific ones isn't a good idea. Doing so doesn't necessarily bind, but could describe them as being something they're not: hibernate based.
My two cents anyway, thanks for listening.
-B