<bean id="configProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="placeholderPrefix" value="${" />
<property name="placeholderSuffix" value="}" />
<property name="locations">
<value>classpath:ddes/config.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${datasource}"/>
<property name="resourceRef" value="true"/>
</bean>
<context:load-time-weaver weaver-class="org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver"/>
<bean id="PersistenceUnit" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="defaultDataSource" ref="dataSource"/>
<property name="class">
<!--LIST BEANS-->
<value>....</value>
</property>
</bean>
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.OraclePlatform"/>
<property name="generateDdl" value="true"/>
<property name="showSql" value="true"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<property name="persistenceUnitManager" ref="PersistenceUnit"/>
<property name="persistenceUnitName" ref="Persistence-ejbPU"/>
<property name="persistenceProvider" ref="org.eclipse.persistence.jpa.PersistenceProvider"/>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="entityManagerFactory"/>
</bean>
埋め込む
@CallByReference
@Stateless(mappedName = "cliente")
public class ClienteDAOBean implements ClienteDAOLocal, ClienteDAORemote {
@PersistenceUnit(unitName = "Persistence-ejbPU")
private EntityManagerFactory emf;
public Clientes find(Integer codCliente) throws Exception {
Clientes cliente = null;
EntityManager em = emf.createEntityManager();
try {
javax.persistence.Query q = em.createNamedQuery("Clientes.findByCodCliente").setParameter("codCliente", codCliente);
cliente = (Clientes) q.getSingleResult();
} catch (Exception e) {
throw e;
} finally {
em.close();
return cliente;
}
}
}
Peroaliniciarlaaplicaciónellogarrojaesteエラー:
'Persistence-ejbPU'という名前の永続性ユニットはスコープPersistence-ejbPU.jarで使用できません
以前はpersistence.xmlファイルを使用していましたが、動的なデータソースの名前が必要でした