Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between configuring data source in persistence.xml and in spring configuration files
    primarykey
    data
    text
    <p>I've seen (and done) data source configuration in two ways (the code below is just for demo): </p> <p>1) configuration inside persistence units, like:</p> <pre><code>&lt;persistence-unit name="LocalDB" transaction-type="RESOURCE_LOCAL"&gt; &lt;class&gt;domain.User&lt;/class&gt; &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt; &lt;properties&gt; &lt;property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/&gt; &lt;property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost"/&gt; &lt;property name="hibernate.hbm2ddl.auto" value="create"/&gt; &lt;property name="hibernate.c3p0.min_size" value="5"/&gt; .... &lt;property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>2) configuration inside spring configuration files (like applicationContext.xml):</p> <pre><code>&lt;bean id="domainEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceUnitName" value="JiraManager"/&gt; &lt;property name="dataSource" ref="domainDataSource"/&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="generateDdl" value="false"/&gt; &lt;property name="showSql" value="false"/&gt; &lt;property name="databasePlatform" value="${hibernate.dialect}"/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="domainDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt; &lt;property name="driverClass" value="${db.driver}" /&gt; &lt;property name="jdbcUrl" value="${datasource.url}" /&gt; &lt;property name="user" value="${datasource.username}" /&gt; &lt;property name="password" value="${datasource.password}" /&gt; &lt;property name="initialPoolSize" value="5"/&gt; &lt;property name="minPoolSize" value="5"/&gt; ..... &lt;/bean&gt; </code></pre> <p>The question is: are there any pros and cons of each way, or it's just a matter of taste?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload