-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error: registry contains more than one (2) entity manager
PostPosted: Thu Dec 20, 2012 7:07 am 
Newbie

Joined: Wed Dec 19, 2012 5:36 am
Posts: 2
After upgrading JPA from 3.6.1 to 4.1.8 I start getting the following error:

"Error: registry contains more than one (2) entity manager factories: PERSISTENCE_UNIT_NAME"

Below you can find a brief summary of our specification requirements.

- User logins in the web application using their own oracle database account.
- The web application only needs to access one database schema;
- The access rights are managed using oracle roles and grant privilegies.
- Only one database schema and multiple user oracle accounts.
- We only set the username and password when users tries to login in the web application.
- The EntityManagerFactory is created using the username and password of the user.

- Because our web application only access one database we only use one persistence unit name.

E.g. persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

<persistence-unit name="PERSISTENCE_UNIT_NAME">
<provider>org.hibernate.ejb.HibernatePersistence</provider>

<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver">
<property name="hibernate.connection.url" value="jdbc:oracle:xx...">
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect">
<property name="hibernate.default_schema" value="SCHEMA_NAME">

<property name="hibernate.connection.username" value="USERNAME">
<property name="hibernate.connection.password" value="PASSWORD">

<property name="hibernate.connection.autocommit" value="false">
<property name="hbm2ddl.auto" value="validate">

<property name="hibernate.show_sql" value="true">
<property name="hibernate.format_sql" value="true">
</properties>
</persistence-unit>
</persistence>


E.g. how we create and close the entity manager factory

Map<String, String> configuration = new ProviderConfiguration();
configuration.put("hibernate.connection.username", username);
configuration.put("hibernate.connection.password", password);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("PERSISTENCE_UNIT_NAME", configuration);
EntityManager em = emf.createEntityManager();
SptrTaxNode t = em.find(SptrTaxNode.class, 9606);
em.close();
emf.close();

Does anyone ever had a similar situation? Any ideas on how can I solve this problem?

Thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.