Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Fwd: Re: AW: Re: AW: [eclipselink-users] How to work with multiple databases/schemas]


--
Andreas König
Developer

andreas.koenig@xxxxxxxxxx

serie a logistics solutions AG
Hülchrather Straße 15
D-50670 Köln

T +49 221 500 60 7-21
F +49 221 500 60 7-07

Vorstand: Axel Löhr, Erwin Soldo
Aufsichtsrat: Adam Musialik (Vors.), Fritz Pleitgen, Hans Jörg Klofat

Amtsgericht Köln HRB 61725

www.serie-a.de


--- Begin Message ---
  • From: Andreas König <andreas.koenig@xxxxxxxxxx>
  • Date: Tue, 05 May 2009 19:19:37 +0200
  • User-agent: Thunderbird 2.0.0.19 (X11/20090105)
Ok, I found the problem. It's totally okay to define multiple datasources (along with their EMF and JPATemplate) in a spring context.
BUT: You have to define a second persistence-unit.
The EMF has configuration-options for injection: persistenceUnitName or persistenceXmlLocation.


Example (with another xml-location):
<bean id="entityManagerFactoryReports"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSourceReports" />
		<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence_rep.xml" />


Thanks everybody!

kOenig



Martin.Berner@xxxxxxxxxxxx wrote:
Hey,
No I dont. I use EclipseLink with GlassfishV3.
I wrote a DataManager-Class in which I have the following functions:

    private EntityManager getPersonalEntityManager(String username) {
        Map emProperties = new HashMap();
        emProperties.put("eclipselink.oracle.proxy-type", oracle.jdbc.OracleConnection.PROXYTYPE_USER_NAME);
        emProperties.put(oracle.jdbc.OracleConnection.PROXY_USER_NAME, username);
        EntityManager em = getEntityManagerFactory().createEntityManager(emProperties);
        return em;
    }

    private EntityManagerFactory getEntityManagerFactory() {
        if (emf == null || !emf.isOpen()){
            emf = Persistence.createEntityManagerFactory(defaultPU);
        }
        return emf;
    }

this give me the ability to work wit diffrent OracleUsers and do not have a pooling and definition for each one. Pooling is done by Glassfish.
Now I'm tring to do the same thing with session and UnitOfWork for EL-Specific Things.

Best regards Martin
--- Originalnachricht ---
Hey.

Thanks for the fast reply. If I use my DB-Client with the same

connection-params (user/pass) the SQL that is rejected by ORA
in the context of the app can be executed without problems.

Just to be sure: You did not try to instantiate multiple
JPATemplates, didn't you?

Regards,
koenig

Berner Martin wrote:
Are you shure the second Schema (OracleUser) has the required previlegue on the other scema and dos the Tabelname you are accessing include the scema in wich the tabele are?
conn userX@DatabaseY
select * from SCOTT.EMPLOYEE;
// instade of select EMPLOYEE wich is not in the curent scema

By side, I also access the Database wit difrent User. I initiali connect as a "Superuser" and set Propertyes by geting an Entitymanager form EntityManagerFactory aquiering a Proxiuser.
The User You are Proxiing must have a "connect THROUGH" Grant. (alter user proxiuser1 grant connect THROUGH Superuser)

Best Regards Martin Berner

-----Ursprüngliche Nachricht-----
Von: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx]Im Auftrag von Andreas
König
Gesendet: Montag, 4. Mai 2009 15:08
An: EclipseLink User Discussions
Betreff: [eclipselink-users] How to work with multiple databases/schemas


Hey there!

We are integrating some reporting functionalities and need to access the ORA-DB as another user than in the rest of the app.
How do I do this?
We're working with spring and I already tried to configure a second jpaTemplate with its own EntitymanagerFactory and own datasource. This doesn't work. I always get the ORA-00942: table or view does not exist.
Obviously the connection doesn't go to the right DB.
Any help?

Greetz,
kÖnig



--
Andreas König
Developer

andreas.koenig@xxxxxxxxxx

serie a logistics solutions AG
Hülchrather Straße 15
D-50670 Köln

T +49 221 500 60 7-21
F +49 221 500 60 7-07

Vorstand: Axel Löhr, Erwin Soldo
Aufsichtsrat: Adam Musialik (Vors.), Fritz Pleitgen, Hans Jörg Klofat

Amtsgericht Köln HRB 61725

www.serie-a.de


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

--
Andreas König
Developer

andreas.koenig@xxxxxxxxxx

serie a logistics solutions AG
Hülchrather Straße 15
D-50670 Köln

T +49 221 500 60 7-21
F +49 221 500 60 7-07

Vorstand: Axel Löhr, Erwin Soldo
Aufsichtsrat: Adam Musialik (Vors.), Fritz Pleitgen, Hans Jörg
Klofat

Amtsgericht Köln HRB 61725

www.serie-a.de




--
Andreas König
Developer

andreas.koenig@xxxxxxxxxx

serie a logistics solutions AG
Hülchrather Straße 15
D-50670 Köln

T +49 221 500 60 7-21
F +49 221 500 60 7-07

Vorstand: Axel Löhr, Erwin Soldo
Aufsichtsrat: Adam Musialik (Vors.), Fritz Pleitgen, Hans Jörg Klofat

Amtsgericht Köln HRB 61725

www.serie-a.de




--- End Message ---

Back to the top