tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karsten Ohme <...@mms-dresden.de>
Subject Using Multiple PersistenceUnits
Date Wed, 13 May 2009 11:55:10 GMT
Hi,

I quote from the spec:

EJB Persistence Spec 6.2:

A persistence unit must have a name. Only one persistence unit of any
given name may be defined
within a single EJB-JAR file, within a single WAR file, within a single
application client jar, or within
an EAR (in the EAR root or lib directory). See Section 6.2.2,
“Persistence Unit Scope”.

So, it is not possible to define multiple persistence units?

But I still tried it with OpenEJB:

> > @Stateless
> > public class HistoryBLWLServiceImpl implements HistoryBLWLService {
> >
> > @PersistenceContext(unitName = "HistoryBLWLCalldataServices")
private EntityManager entityManagerCalldata;

@PersistenceContext(unitName = "HistoryBLWLCockpitServices")
private EntityManager entityManagerCockpit;
...

persistence.xml:

...
<persistence-unit name="HistoryBLWLCalldataServices"
transaction-type="JTA">
<jta-data-source>monaco/datasource/calldata</jta-data-source>

<non-jta-data-source>monaco/datasource/calldata-unmanaged</non-jta-data-source>


<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.KEP</class>


<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.KEPHistory</class>

<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.CallerHistory</class>

<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.BonusPoints</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
<persistence-unit name="HistoryBLWLCockpitServices"
transaction-type="JTA">
<jta-data-source>monaco/datasource/cockpit</jta-data-source>

 <non-jta-data-source>monaco/datasource/cockpit-unmanaged</non-jta-data-source>

<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.ActionType</class>


<class>de.mms_dresden.cgm_platt.monaco.api.test.history_bl_wl.vo.KEPAction</class>

 <exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
...

OpenEJB Config:
>
> > ...
> > <Resource id="HistoryBLWLCalldataServices" type="javax.sql.DataSource">
> >   JdbcDriver com.mysql.jdbc.Driver
> >   JdbcUrl
> jdbc:mysql://wum08071.mms-dresden.de:3307/ssc_monaco_0_9_calldata_test
> >   UserName cgsdb
> >   Password cgsdb
> >   JtaManaged true
> > </Resource>
> > <Resource id="HistoryBLWLCockpitServices" type="javax.sql.DataSource">
> >   JdbcDriver com.mysql.jdbc.Driver
> >   JdbcUrl
> jdbc:mysql://wum08071.mms-dresden.de:3307/ssc_monaco_0_9_cockpit_test
> >   UserName cgsdb
> >   Password cgsdb
> >   JtaManaged true
> > </Resource>
> > ...
>

Log:

>
> > Configuring Service(id=HistoryBLWLCalldataServices, type=Resource,
> provider-id=Default JDBC Database)
> > Configuring Service(id=HistoryBLWLCockpitServices, type=Resource,
> provider-id=Default JDBC Database)
> > Found EjbModule in classpath:
> D:\cgm\monaco_0.9.0\workspace\monaco\impl\test\history_bl_wl\service\target\classes
>
> > Found EjbModule in classpath:
> D:\repository\de\mms_dresden\test.ejb.openejb\0.0.3\test.ejb.openejb-0.0.3.jar
>
> > Beginning load:
> D:\cgm\monaco_0.9.0\workspace\monaco\impl\test\history_bl_wl\service\target\classes
>
> > Beginning load:
> D:\repository\de\mms_dresden\test.ejb.openejb\0.0.3\test.ejb.openejb-0.0.3.jar
>
> > Configuring enterprise application: classpath.ear
> > Configuring Service(id=Default Stateless Container, type=Container,
> provider-id=Default Stateless Container)
> > Auto-creating a container for bean classes/HistoryBLWLServiceImpl:
> Container(type=STATELESS, id=Default Stateless Container)
> > Configuring PersistenceUnit(name=HistoryBLWLCalldataServices)
> > Auto-creating a Resource with id 'HistoryBLWLCalldataServicesNonJta'
> of type 'DataSource for 'HistoryBLWLCalldataServices'.
> > Configuring Service(id=HistoryBLWLCalldataServicesNonJta,
> type=Resource, provider-id=HistoryBLWLCalldataServices)
> > Adjusting HistoryBLWLCalldataServices <jta-data-source> to
> 'HistoryBLWLCalldataServices'
> > Adjusting HistoryBLWLCalldataServices <non-jta-data-source> to
> 'HistoryBLWLCalldataServicesNonJta'
> > Configuring PersistenceUnit(name=HistoryBLWLCockpitServices)
> > Adjusting HistoryBLWLCockpitServices <jta-data-source> to
> 'HistoryBLWLCalldataServices'
> > Adjusting HistoryBLWLCockpitServices <non-jta-data-source> to
> 'HistoryBLWLCalldataServicesNonJta'

The last two lines are confusing.

> When I make a call:
>
> > JDBCExceptionReporter: Table
> 'ssc_monaco_0_9_calldata_test.test_kep_action' doesn't exist
>

What's the problem?

BR,
Karsten

Mime
View raw message