Persistence.xml example for a production instance using jpa2 and hibernate 3.6.x
It depends :) you can set cache sizes, sampling depth (for external connections), batch size selection and much more.
You probably don't want to write too much (show_sql => set to false, format_sql => set to false, use_sql_comments => set to false).
But actually it depends, and you have to measure.
It is also important to use and properly configure the connection pool. And here: use common sense and measure.
We hope you find these links helpful:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html
The decisive moment is the right model. Performance will be a problem if many sql queries are generated that make massive joins. Therefore, if performance is critical, you need to spend some thinking on normalizing or not really doing too much normalization in entity modeling.
In addition, collections and how you simulate / process them can play a big role in terms of performance.
And as for caching: depending on your use case, you can improve performance over long lengths if you correctly configured the second-level cache (for example, Ehcache). This again means: think about what can be cached and what is not, and how durable and how large your caches should be. So it really depends on :)
I google'd for various combinations of useful keywords, and I came up with some useful links to point you in the right direction. Just remember that there will not be ONE, DEFINED list of βrightβ properties for the production environment. People will recommend things based on their experience, but you will have to try everything and use common sense to find out what works best for you.
Hibernate Documentation of Available Custom Properties
Example persistence.xml file for MySql
The only property I have ever had to consciously remember for PROD configurations is the hibernate.hbm2ddl.auto property, which allows Hibernate to directly modify your database schema by automatically executing DDL statements. For test databases, it often makes sense to use the "create-drop" value so that the SessionFactory test creates the necessary tables for you or changes existing ones to meet possible recent changes to the schema. On prod, you do NOT want Hibernate to mess with your circuit. Even the Hibernate guys warn that they do not use this feature in a production environment because data integrity is not guaranteed. The value you should use for prod is "validate", which simply checks that the DB you are connecting to has the correct schema to which the Hibernate objects are attached, and it will not be able to load the SessionFactory if there are any discrepancies.