Hi,
I am trying to unit test a DAO.
I am using Hibernate with JPA.
I create the entity manager like this in my Junit code :
Code:
EntityManagerFactory factory = Persistence.createEntityManagerFactory ( "central1" );
em = factory.createEntityManager ( );
This is my persistence.xml :
Code:
<?xml version="1.0"?>
<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="central1" transaction-type="RESOURCE_LOCAL">
<class>com.sample.common.entity.Area</class>
<class>com.sample.common.entity.SomeArea</class>
<properties>
<property name="javax.persistence.jdbc.user" value="csmart"/>
<property name="javax.persistence.jdbc.password" value="csmart"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@12.12.112.150:1521:ccon"/>
</properties>
</persistence-unit>
</persistence>
When i execute the Query, I get the following exception:
Code:
>java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
I could not get any info from searching on the web. Any help would be appreciated.
Thanks
Venu