9. JNDI
<div class="sectionbody">
<div class="paragraph">
Hibernate does optionally interact with JNDI on the application’s behalf.
Generally, it does this when the application:
</div>
<div class="ulist">
- has asked the SessionFactory be bound to JNDI
- has specified a DataSource to use by JNDI name
is using JTA transactions and the
JtaPlatformneeds to do JNDI lookups forTransactionManager,UserTransaction, etc </div>All of these JNDI calls route through a single service whose role is
org.hibernate.engine.jndi.spi.JndiService. The standardJndiServiceaccepts a number of configuration settings</div>
- `hibernate.jndi.class`
names the javax.naming.InitialContext implementation class to use. See
javax.naming.Context#INITIAL_CONTEXT_FACTORY</dd>
- `hibernate.jndi.url`
names the JNDI InitialContext connection url. See
javax.naming.Context.PROVIDER_URL</dd> </dl> </div>
Any other settings prefixed with
hibernate.jndi.will be collected and passed along to the JNDI provider.</div>
</td>
The standard
JndiServiceassumes that all JNDI calls are relative to the sameInitialContext. If your application uses multiple naming servers for whatever reason, you will need a customJndiServiceimplementation to handle those details.</div> </td> </tr> </table> </div> </div> </div>