Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.0.CR1
I am having a problem obtaining EntityManager in JBoss. I specified my persistence.xml file
Code:
<persistence 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"
version="1.0">
<persistence-unit name="hibernateUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/OracleDS</jta-data-source>
<class>StatusInfo</class>
<properties>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
</properties>
</persistence-unit>
</persistence>
The following code I used to obtain the EntityManager
Code:
configOverrides.put("hibernate.connection.url", "jdbc:oracle:thin:@host:1521:instance");
configOverrides.put("hibernate.connection.username", "myuser");
configOverrides.put("hibernate.connection.password", "pass");
EntityManagerFactory programmaticEmf =
Persistence.createEntityManagerFactory("hibernateUnit", configOverrides);
em = programmaticEmf.createEntityManager();
Now when I try to run my ejb component I will get an exception
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jca:name=OracleDS,service=ManagedConnectionFactory
State: NOTYETINSTALLED
Depends On Me:
persistence.units:ear=harvest.ear,jar=ejb.harvest.jar,unitName=hibernateUnit
Only after I configure a dataSource in my oracle-ds.xml file with the same jndi-name will the code work.
My use cases requires me to get connectionUrl, userName and password as params from the client and then obtain a connection and do some db logic. I haven't been able to figure out how to do this properly without first initializing a datasource. I thought that simply by passing in Map with my jdbc properties as mentioned above would do the trick.
Any help would be appreciated,
Thanks