Quote:
I know that Hibernate makes use of hbm.xml files, but what I'm not sure about is their sparseness: is it possible to do the bulk of my configuration using JPA annotations and then place certain mapping attributes sparsely into hbm.xml fragments?
...and the answer is, no, it is not. Once Hibernate picks up an hbm.xml file it regards it as being the canonical source of mapping information.
I tried creating a DTD-conformant hbm.xml file, and put the minimum amount of mapping information in it that I could. I wanted to specify only that a given boolean field should be run through the Hibernate "yes_no" converter during mapping operations. As I realized that in order to make the hbm.xml file parse correctly I'd have to put in an <id> element, I got that sinking feeling. :-)
Sure enough, although it was discovered automatically by the Hibernate EntityManager implementation (that's cool) it was treated as though it were the be-all and end-all of mapping information for the class it described (that's not cool). That is, unlike a JPA orm.xml file, which "fills in the gaps" where annotations have not specified all the information (if metadata-complete has not been specified), the hbm.xml file seems to simply be treated as the last word on mapping information. So you have to populate it fully, not sparsely.
This means that if I want to make use of the many very useful Hibernate extensions--but if I don't want to ship with the hibernate annotations jar--then I have to create complete mapping files for all of my JPA entities. Sniff.
I would love to be proven wrong here, and am hoping someone will do so.
Best,
Laird