im using hibernate and i maps my entities with annotations (so no xml files).
I finally decided to try spring framework but I encountered some problems to make it work.
All tutorials i found are very dispersive and most of them use xml file to map an entity…
Can you help me to correctly write a xml config file for spring+hibernate?
Thanks.
The following is a working example from one of my apps.
They should all go in the applicationContext or in a .xml loaded by the appContext.
The first snippet is the configuration of the datasource, using connection pooling:
Next up is a Property bean. If you are unsure about any of these settings, please refer to the corresponding APIs.
Now this is the interesting part. Here you wire it all together and tell the sessionfactory where to look for annotated Classes (packagesToScan).
To make this example work, you should use the following dependencies (given for maven):
When you have setup your project like this, the following @Entity mappings are managed by spring automatically:
If you have any further questions, please let me know.
greetings