0

I have an Java app, which i used to test with this persistence unit with in memory Derby driver:

<persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
  <property name="hibernate.connection.url" value="jdbc:derby:memory:ProjectDB"/>
  <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
  <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  <property name="hibernate.connection.username" value=""/>
  <property name="hibernate.connection.password" value=""/>
</properties>

Now i added an EJB service layer and i have been unable to write a working persistence unit using the same in memory db since. The following works fine, but i'd like to have it in memory

<persistence-unit name="moduleNamePU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/sample</jta-data-source>
<properties>
  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>

How can i alter the second persistence unit in order to work with in memory db?

EDIT: As an EJB container i use Glassfish 3.1

Entity Service:

@Stateless
@Local(value=EntityServiceLocal.class)
public class EntityService implements EntityServiceLocal {

    @EJB
    private EntityDaoLocal entityDao;

    @Resource
    private SessionContext ctx;

    public void setEntityDao(EntityDaoLocal entityDao) {
        this.entityDao = entityDao;
    }
}

Dao Layer service:

@Stateless
public class EntityDao implements EntityDaoLocal {

    @PersistenceContext
    private EntityManager em;
}
Ondrej Sotolar
  • 1,352
  • 1
  • 19
  • 29
  • Could you provide more details as to - what's your EJB container (jboss, weblogic, OpenEJB )? How is your datasource created? Please post your datasource configuration code. – Sashi Nov 05 '12 at 05:29
  • I edited my post so as to provide the answers. If you need any more, please tell me. – Ondrej Sotolar Nov 05 '12 at 08:19
  • Thanks for the addition. Have you created a datasource in Glassfish with jndi name set to 'jdbc/sample' ? – Sashi Nov 05 '12 at 13:53
  • You mean via web.xml and glassfish-web.xml? No, not yet. – Ondrej Sotolar Nov 05 '12 at 15:44
  • Looks like that's what you are missing. Please follow this tutorial to create a datasource using glassfish admin console. Make sure your jndi datasource name is 'jdbc/sample'. http://musabalrawi.com/2011/06/configure-datasource-on-glassfish/ – Sashi Nov 05 '12 at 17:38

0 Answers0