You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mikeho <mi...@fundamo.com> on 2009/08/18 18:40:31 UTC

Embedded OpenEJB does not seem to be flushing to the DB on commit



Hi,

Essentially what I am trying to is:
  1) create a EntityManagerFactory outside of the container and use its em
to persist some fixtures.
	
	final Properties p = new Properties();
        p.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
        p.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:hsqldb");
        p.put("eclipselink.target-database",
                "org.eclipse.persistence.platform.database.HSQLPlatform");
        p.put("javax.persistence.jdbc.user", "sa");
        p.put("javax.persistence.jdbc.password", "");
        p.put("eclipselink.ddl-generation", "drop-and-create-tables");
        p.put("eclipselink.ddl-generation.output-mode", "database");
	emf = Persistence.createEntityManagerFactory(
                    this.persistenceUnitName, p);

  2) I then create the InitialContext using the properties below:

	final Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,
 
        p.put("jdbc/BrandGroupXADS", "new://Resource?type=DataSource");
        p.put("jdbc/BrandGroupXADS.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("jdbc/BrandGroupXADS.JdbcUrl", "jdbc:hsqldb:mem:hsqldb");
        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.user", "sa");
        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.password", "");
        p.put("jdbc/BrandGroupXADS.eclipselink.target-database",
                "org.eclipse.persistence.platform.database.HSQLPlatform");
  
  3) The persistence.xml looks like this (note no properties just the
classes):

 	<persistence-unit name="brandgroupPU" > 
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
		<jta-data-source>jdbc/BrandGroupXADS</jta-data-source>

	        classes...

	     </persistence-unit>
	</persistence>
 	
   4) I now do a jndi lookup for a staleless session bean and invoke a
method to return the entity(s) persisted in step 1).
      It does this happily.

   5) I then invove a method on the same SSB to insert another entity. CMP
is used.

   6) I repeat step 4) and the entity applied in step 5) does not appear in
the result list.

   7) I do have the following arg on my cammand
line:-javaagent:{path}/openejb-javaagent-3.0.jar


I've looked on the forum and tried various things. I'm beginning to think
that I am overlooking something simple. Plse Help.

Using:
Apache OpenEJB 3.1.1    build: 20090530-06:18
EclipseLink 2.0.0
hsqldb 1.8.0

Thnking you anticipation

Regards

Mike
-- 
View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25028791.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by mikeho <mi...@fundamo.com>.
Hi,

I finally figured out what the issue was. It turns out that it was not
OpenEJB but rather a eclipselink property when creating the
EntityManagerFactory outside the container. 

Here is the extract from the elipselink
website(http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Session.2C_Target_Database_and_Target_Application_Server):


eclipselink.session-name 
 Specify the name by which the EclipseLink session is stored in the static
session manager. Use this option if you need to access the EclipseLink
shared session outside of the context of the JPA or to use a pre-existing
EclipseLink session configured through an EclipseLink sessions.xml file. 

Valid values: a valid EclipseLink session name that is unique in a server
deployment. 


Example: persistence.xml file 

<property name="eclipselink.session-name" value="MySession"/>
Example: property Map 

import org.eclipse.persistence.config.PersistenceUnitProperties;
propertiesMap.put(PersistenceUnitProperties.SESSION_NAME, "MySession");  

Regards,

MikeHo

David Blevins wrote:
> 
> 
> On Aug 19, 2009, at 8:19 AM, mikeho wrote:
> 
>>
>> Hi Daivid,
>>
>> Firstly thanks for the reply.
>>
>> My aim is to use the Fit framework and embedded OpenEJB to test an
>> application.
>> I intend using fit fixtures to set up test data and fit fixtures to  
>> invoke
>> the various session beans.
>>
>> So in my test setup I beginTx() write a row to the db and commitTx()
>>
>> I then insert another entity (for the same table) via the SSB (default
>> transaction settings ie CMP tx.required).
>>
>> I then invoke a method on the SSB which should return a list of all  
>> the
>> entities in the table. This is the result list I refer to earlier.  
>> This list
>> only contains the rows I commited in the setup. The entity inserted  
>> via the
>> SSB is not in the list.
> 
> Ok, I see.  If you can create a small test case for this, I'll be  
> happy to take a look.
> 
> A side note on acronyms, I think you mean CMT (Container-Managed  
> Transactions) instead of CMP (Container-Managed Persistence).  CMP was  
> the old javax.ejb.EntityBean persistence model that was obsoleted by  
> the new javax.persistence API.
> 
>> Feed-back
>> (A) I assume then that if I do a lookup of the EntityManagerFactory  
>> (or get
>> injected into my #LocalClient) that ny EMs created by it will be  
>> able to
>> access the entities inserted/updated by the container?
> 
> Right.  I doesn't matter what persistence technology does the  
> inserting/updating as long as the data is flushed to the database.   
> Using two at the same time in the same transaction would be a big no- 
> no, but it doesn't sound like you're doing that.
> 
>> I could use this
>> mechanism to set up my test fixtures. Would I use the  
>> UserTransaction or the
>> EntityTransaction API to begin/commit these transactions?
> 
> Sure, we have an example that does exactly that using the  
> UserTransaction:
> 
> http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1.1/examples/testcase-injection/
> 
> Here the setup is done in the test case via directly using an  
> EntityManagerFactory.  The entities inserted are later read via a  
> Stateful bean using an EntityManager.
> 
>> (B) The containers db pool is indeed pinting to the same db and is  
>> container
>> managed. You correct in your assumption that there is no active  
>> transaction
>> when the methods on the SSB are invoked. And what you describe is the
>> behaviour that I expected.
>>
>> (C) the insert and read methods are on the same Stateless Session  
>> Bean and
>> reference the same EJB entity.
>>
>> I am very excited by the benefits that this product offers in  
>> testing. Both
>> for functional and regression testing.
> 
> There's likely something simple going on.  Should be pretty clear with  
> a small test case to reproduce the situation.
> 
> -David
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25257021.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by David Blevins <da...@visi.com>.
On Aug 19, 2009, at 8:19 AM, mikeho wrote:

>
> Hi Daivid,
>
> Firstly thanks for the reply.
>
> My aim is to use the Fit framework and embedded OpenEJB to test an
> application.
> I intend using fit fixtures to set up test data and fit fixtures to  
> invoke
> the various session beans.
>
> So in my test setup I beginTx() write a row to the db and commitTx()
>
> I then insert another entity (for the same table) via the SSB (default
> transaction settings ie CMP tx.required).
>
> I then invoke a method on the SSB which should return a list of all  
> the
> entities in the table. This is the result list I refer to earlier.  
> This list
> only contains the rows I commited in the setup. The entity inserted  
> via the
> SSB is not in the list.

Ok, I see.  If you can create a small test case for this, I'll be  
happy to take a look.

A side note on acronyms, I think you mean CMT (Container-Managed  
Transactions) instead of CMP (Container-Managed Persistence).  CMP was  
the old javax.ejb.EntityBean persistence model that was obsoleted by  
the new javax.persistence API.

> Feed-back
> (A) I assume then that if I do a lookup of the EntityManagerFactory  
> (or get
> injected into my #LocalClient) that ny EMs created by it will be  
> able to
> access the entities inserted/updated by the container?

Right.  I doesn't matter what persistence technology does the  
inserting/updating as long as the data is flushed to the database.   
Using two at the same time in the same transaction would be a big no- 
no, but it doesn't sound like you're doing that.

> I could use this
> mechanism to set up my test fixtures. Would I use the  
> UserTransaction or the
> EntityTransaction API to begin/commit these transactions?

Sure, we have an example that does exactly that using the  
UserTransaction:

http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1.1/examples/testcase-injection/

Here the setup is done in the test case via directly using an  
EntityManagerFactory.  The entities inserted are later read via a  
Stateful bean using an EntityManager.

> (B) The containers db pool is indeed pinting to the same db and is  
> container
> managed. You correct in your assumption that there is no active  
> transaction
> when the methods on the SSB are invoked. And what you describe is the
> behaviour that I expected.
>
> (C) the insert and read methods are on the same Stateless Session  
> Bean and
> reference the same EJB entity.
>
> I am very excited by the benefits that this product offers in  
> testing. Both
> for functional and regression testing.

There's likely something simple going on.  Should be pretty clear with  
a small test case to reproduce the situation.

-David


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by mikeho <mi...@fundamo.com>.
Hi Daivid,

Firstly thanks for the reply.

My aim is to use the Fit framework and embedded OpenEJB to test an
application.
I intend using fit fixtures to set up test data and fit fixtures to invoke
the various session beans.

So in my test setup I beginTx() write a row to the db and commitTx()

I then insert another entity (for the same table) via the SSB (default
transaction settings ie CMP tx.required).

I then invoke a method on the SSB which should return a list of all the
entities in the table. This is the result list I refer to earlier. This list
only contains the rows I commited in the setup. The entity inserted via the
SSB is not in the list.

Feed-back
(A) I assume then that if I do a lookup of the EntityManagerFactory (or get
injected into my #LocalClient) that ny EMs created by it will be able to
access the entities inserted/updated by the container? I could use this
mechanism to set up my test fixtures. Would I use the UserTransaction or the
EntityTransaction API to begin/commit these transactions?

(B) The containers db pool is indeed pinting to the same db and is container
managed. You correct in your assumption that there is no active transaction
when the methods on the SSB are invoked. And what you describe is the
behaviour that I expected.
 
(C) the insert and read methods are on the same Stateless Session Bean and
reference the same EJB entity.

I am very excited by the benefits that this product offers in testing. Both
for functional and regression testing.

Thank you,

Regards,

Mike Hopley




David Blevins wrote:
> 
> Hi Mike,
> 
> If you could explain a bit on our goals that would helpful.  From the  
> description it sounds like you're testing all possible ways to persist  
> data.  If I understand correctly, you have this setup:
> 
>   (A) 1.  An EntityManagerFactory created by you outside the container  
> -- this EMF and any EntityManagers are not container aware, will not  
> use the container db pool, and will not participate in container  
> created transactions.  The EntityTransaction API must be used to start/ 
> stop transactions.  Data will not be guaranteed to flush outside of an  
> EntityTransaction.
> 
>   (B) 2-4.  An EntityManager is injected/looked up in your Stateless  
> bean -- not an EntityManagerFactory  (correct me if I'm wrong).  This  
> EntityManager is pointing to the same database, but will be using the  
> container's connection pool and a container controlled datasource.   
> The EntityManager will participate in JTA transactions.  No details  
> were given as to who or how the Stateless bean is invoked, so I assume  
> there is no transaction in progress.  In that case the container will  
> begin and commit a new transaction around each call to the Stateless  
> bean.  Under the covers a new EntityManager instance will be created  
> at the beginning of each transaction and flushed at the end of each  
> transaction.
> 
>   (C) 5.  The same Stateless bean also has a reference to an EJB 2.x  
> Container-Managed Persistence EntityBean.  Is that right?  How is this  
> 2.x CMP EntityBean configured?
> 
>   6.  When you say "the result list", which persistence approach are  
> you using to read the data; A, B or C?
> 
> Just as a general note, the three persistence approaches (A, B, and C)  
> will have zero awareness of each other and will not see the data of  
> the other till the "cache" they hold is flushed to the database.  This  
> will be around transactional boundaries by default.  If any of them  
> are used in the same transaction, you will have consistency and  
> integrity issues if they attempt to operate on the same data.  The  
> same thing can happen if data is passed between them at any time which  
> can result in dirty reads.
> 
> If you have some insight on your goals and design constraints, that  
> would be very helpful.
> 
> Look forward to your info, hope we can point you in the right direction.
> 
> -David
> 
> 
> On Aug 18, 2009, at 9:40 AM, mikeho wrote:
> 
>>
>>
>>
>> Hi,
>>
>> Essentially what I am trying to is:
>>  1) create a EntityManagerFactory outside of the container and use  
>> its em
>> to persist some fixtures.
>> 	
>> 	final Properties p = new Properties();
>>        p.put("javax.persistence.jdbc.driver",  
>> "org.hsqldb.jdbcDriver");
>>        p.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:hsqldb");
>>        p.put("eclipselink.target-database",
>>                 
>> "org.eclipse.persistence.platform.database.HSQLPlatform");
>>        p.put("javax.persistence.jdbc.user", "sa");
>>        p.put("javax.persistence.jdbc.password", "");
>>        p.put("eclipselink.ddl-generation", "drop-and-create-tables");
>>        p.put("eclipselink.ddl-generation.output-mode", "database");
>> 	emf = Persistence.createEntityManagerFactory(
>>                    this.persistenceUnitName, p);
>>
>>  2) I then create the InitialContext using the properties below:
>>
>> 	final Properties p = new Properties();
>>        p.put(Context.INITIAL_CONTEXT_FACTORY,
>>
>>        p.put("jdbc/BrandGroupXADS", "new://Resource?type=DataSource");
>>        p.put("jdbc/BrandGroupXADS.JdbcDriver",  
>> "org.hsqldb.jdbcDriver");
>>        p.put("jdbc/BrandGroupXADS.JdbcUrl", "jdbc:hsqldb:mem:hsqldb");
>>        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.user", "sa");
>>        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.password", "");
>>        p.put("jdbc/BrandGroupXADS.eclipselink.target-database",
>>                 
>> "org.eclipse.persistence.platform.database.HSQLPlatform");
>>
>>  3) The persistence.xml looks like this (note no properties just the
>> classes):
>>
>> 	<persistence-unit name="brandgroupPU" >
>> 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
>> 		<jta-data-source>jdbc/BrandGroupXADS</jta-data-source>
>>
>> 	        classes...
>>
>> 	     </persistence-unit>
>> 	</persistence>
>> 	
>>   4) I now do a jndi lookup for a staleless session bean and invoke a
>> method to return the entity(s) persisted in step 1).
>>      It does this happily.
>>
>>   5) I then invove a method on the same SSB to insert another  
>> entity. CMP
>> is used.
>>
>>   6) I repeat step 4) and the entity applied in step 5) does not  
>> appear in
>> the result list.
>>
>>   7) I do have the following arg on my cammand
>> line:-javaagent:{path}/openejb-javaagent-3.0.jar
>>
>>
>> I've looked on the forum and tried various things. I'm beginning to  
>> think
>> that I am overlooking something simple. Plse Help.
>>
>> Using:
>> Apache OpenEJB 3.1.1    build: 20090530-06:18
>> EclipseLink 2.0.0
>> hsqldb 1.8.0
>>
>> Thnking you anticipation
>>
>> Regards
>>
>> Mike
>> -- 
>> View this message in context:
>> http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25028791.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25046195.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by David Blevins <da...@visi.com>.
Hi Mike,

If you could explain a bit on our goals that would helpful.  From the  
description it sounds like you're testing all possible ways to persist  
data.  If I understand correctly, you have this setup:

  (A) 1.  An EntityManagerFactory created by you outside the container  
-- this EMF and any EntityManagers are not container aware, will not  
use the container db pool, and will not participate in container  
created transactions.  The EntityTransaction API must be used to start/ 
stop transactions.  Data will not be guaranteed to flush outside of an  
EntityTransaction.

  (B) 2-4.  An EntityManager is injected/looked up in your Stateless  
bean -- not an EntityManagerFactory  (correct me if I'm wrong).  This  
EntityManager is pointing to the same database, but will be using the  
container's connection pool and a container controlled datasource.   
The EntityManager will participate in JTA transactions.  No details  
were given as to who or how the Stateless bean is invoked, so I assume  
there is no transaction in progress.  In that case the container will  
begin and commit a new transaction around each call to the Stateless  
bean.  Under the covers a new EntityManager instance will be created  
at the beginning of each transaction and flushed at the end of each  
transaction.

  (C) 5.  The same Stateless bean also has a reference to an EJB 2.x  
Container-Managed Persistence EntityBean.  Is that right?  How is this  
2.x CMP EntityBean configured?

  6.  When you say "the result list", which persistence approach are  
you using to read the data; A, B or C?

Just as a general note, the three persistence approaches (A, B, and C)  
will have zero awareness of each other and will not see the data of  
the other till the "cache" they hold is flushed to the database.  This  
will be around transactional boundaries by default.  If any of them  
are used in the same transaction, you will have consistency and  
integrity issues if they attempt to operate on the same data.  The  
same thing can happen if data is passed between them at any time which  
can result in dirty reads.

If you have some insight on your goals and design constraints, that  
would be very helpful.

Look forward to your info, hope we can point you in the right direction.

-David


On Aug 18, 2009, at 9:40 AM, mikeho wrote:

>
>
>
> Hi,
>
> Essentially what I am trying to is:
>  1) create a EntityManagerFactory outside of the container and use  
> its em
> to persist some fixtures.
> 	
> 	final Properties p = new Properties();
>        p.put("javax.persistence.jdbc.driver",  
> "org.hsqldb.jdbcDriver");
>        p.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:hsqldb");
>        p.put("eclipselink.target-database",
>                 
> "org.eclipse.persistence.platform.database.HSQLPlatform");
>        p.put("javax.persistence.jdbc.user", "sa");
>        p.put("javax.persistence.jdbc.password", "");
>        p.put("eclipselink.ddl-generation", "drop-and-create-tables");
>        p.put("eclipselink.ddl-generation.output-mode", "database");
> 	emf = Persistence.createEntityManagerFactory(
>                    this.persistenceUnitName, p);
>
>  2) I then create the InitialContext using the properties below:
>
> 	final Properties p = new Properties();
>        p.put(Context.INITIAL_CONTEXT_FACTORY,
>
>        p.put("jdbc/BrandGroupXADS", "new://Resource?type=DataSource");
>        p.put("jdbc/BrandGroupXADS.JdbcDriver",  
> "org.hsqldb.jdbcDriver");
>        p.put("jdbc/BrandGroupXADS.JdbcUrl", "jdbc:hsqldb:mem:hsqldb");
>        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.user", "sa");
>        p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.password", "");
>        p.put("jdbc/BrandGroupXADS.eclipselink.target-database",
>                 
> "org.eclipse.persistence.platform.database.HSQLPlatform");
>
>  3) The persistence.xml looks like this (note no properties just the
> classes):
>
> 	<persistence-unit name="brandgroupPU" >
> 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> 		<jta-data-source>jdbc/BrandGroupXADS</jta-data-source>
>
> 	        classes...
>
> 	     </persistence-unit>
> 	</persistence>
> 	
>   4) I now do a jndi lookup for a staleless session bean and invoke a
> method to return the entity(s) persisted in step 1).
>      It does this happily.
>
>   5) I then invove a method on the same SSB to insert another  
> entity. CMP
> is used.
>
>   6) I repeat step 4) and the entity applied in step 5) does not  
> appear in
> the result list.
>
>   7) I do have the following arg on my cammand
> line:-javaagent:{path}/openejb-javaagent-3.0.jar
>
>
> I've looked on the forum and tried various things. I'm beginning to  
> think
> that I am overlooking something simple. Plse Help.
>
> Using:
> Apache OpenEJB 3.1.1    build: 20090530-06:18
> EclipseLink 2.0.0
> hsqldb 1.8.0
>
> Thnking you anticipation
>
> Regards
>
> Mike
> -- 
> View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25028791.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by mikeho <mi...@fundamo.com>.
The only things I have in the DB are the entites I added outside of the
container.


Jean-Louis MONTEIRO wrote:
> 
> Hello Mike,
> 
> The default transaction configuration is REQUIRED for a session bean. So
> each time you call your stateless method, a transaction is created and
> committed (or rollbacked). So after the first call to 5 you should have
> something in the database.
> 
> do you ?
> 
> Jean-Louis
> 
> 
> 
> mikeho wrote:
>> 
>> 
>> 
>> Hi,
>> 
>> Essentially what I am trying to is:
>>   1) create a EntityManagerFactory outside of the container and use its
>> em to persist some fixtures.
>> 	
>> 	final Properties p = new Properties();
>>         p.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
>>         p.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:hsqldb");
>>         p.put("eclipselink.target-database",
>>                
>> "org.eclipse.persistence.platform.database.HSQLPlatform");
>>         p.put("javax.persistence.jdbc.user", "sa");
>>         p.put("javax.persistence.jdbc.password", "");
>>         p.put("eclipselink.ddl-generation", "drop-and-create-tables");
>>         p.put("eclipselink.ddl-generation.output-mode", "database");
>> 	emf = Persistence.createEntityManagerFactory(
>>                     this.persistenceUnitName, p);
>> 
>>   2) I then create the InitialContext using the properties below:
>> 
>> 	final Properties p = new Properties();
>>         p.put(Context.INITIAL_CONTEXT_FACTORY,
>>  
>>         p.put("jdbc/BrandGroupXADS", "new://Resource?type=DataSource");
>>         p.put("jdbc/BrandGroupXADS.JdbcDriver", "org.hsqldb.jdbcDriver");
>>         p.put("jdbc/BrandGroupXADS.JdbcUrl", "jdbc:hsqldb:mem:hsqldb");
>>         p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.user", "sa");
>>         p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.password", "");
>>         p.put("jdbc/BrandGroupXADS.eclipselink.target-database",
>>                
>> "org.eclipse.persistence.platform.database.HSQLPlatform");
>>   
>>   3) The persistence.xml looks like this (note no properties just the
>> classes):
>> 
>>  	<persistence-unit name="brandgroupPU" > 
>> 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
>> 		<jta-data-source>jdbc/BrandGroupXADS</jta-data-source>
>> 
>> 	        classes...
>> 
>> 	     </persistence-unit>
>> 	</persistence>
>>  	
>>    4) I now do a jndi lookup for a staleless session bean and invoke a
>> method to return the entity(s) persisted in step 1).
>>       It does this happily.
>> 
>>    5) I then invove a method on the same SSB to insert another entity.
>> CMP is used.
>> 
>>    6) I repeat step 4) and the entity applied in step 5) does not appear
>> in the result list.
>> 
>>    7) I do have the following arg on my cammand
>> line:-javaagent:{path}/openejb-javaagent-3.0.jar
>> 
>> 
>> I've looked on the forum and tried various things. I'm beginning to think
>> that I am overlooking something simple. Plse Help.
>> 
>> Using:
>> Apache OpenEJB 3.1.1    build: 20090530-06:18
>> EclipseLink 2.0.0
>> hsqldb 1.8.0
>> 
>> Thnking you anticipation
>> 
>> Regards
>> 
>> Mike
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25045479.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Embedded OpenEJB does not seem to be flushing to the DB on commit

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
Hello Mike,

The default transaction configuration is REQUIRED for a session bean. So
each time you call your stateless method, a transaction is created and
committed (or rollbacked). So after the first call to 5 you should have
something in the database.

do you ?

Jean-Louis



mikeho wrote:
> 
> 
> 
> Hi,
> 
> Essentially what I am trying to is:
>   1) create a EntityManagerFactory outside of the container and use its em
> to persist some fixtures.
> 	
> 	final Properties p = new Properties();
>         p.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
>         p.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:hsqldb");
>         p.put("eclipselink.target-database",
>                 "org.eclipse.persistence.platform.database.HSQLPlatform");
>         p.put("javax.persistence.jdbc.user", "sa");
>         p.put("javax.persistence.jdbc.password", "");
>         p.put("eclipselink.ddl-generation", "drop-and-create-tables");
>         p.put("eclipselink.ddl-generation.output-mode", "database");
> 	emf = Persistence.createEntityManagerFactory(
>                     this.persistenceUnitName, p);
> 
>   2) I then create the InitialContext using the properties below:
> 
> 	final Properties p = new Properties();
>         p.put(Context.INITIAL_CONTEXT_FACTORY,
>  
>         p.put("jdbc/BrandGroupXADS", "new://Resource?type=DataSource");
>         p.put("jdbc/BrandGroupXADS.JdbcDriver", "org.hsqldb.jdbcDriver");
>         p.put("jdbc/BrandGroupXADS.JdbcUrl", "jdbc:hsqldb:mem:hsqldb");
>         p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.user", "sa");
>         p.put("jdbc/BrandGroupXADS.eclipselink.jdbc.password", "");
>         p.put("jdbc/BrandGroupXADS.eclipselink.target-database",
>                 "org.eclipse.persistence.platform.database.HSQLPlatform");
>   
>   3) The persistence.xml looks like this (note no properties just the
> classes):
> 
>  	<persistence-unit name="brandgroupPU" > 
> 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
> 		<jta-data-source>jdbc/BrandGroupXADS</jta-data-source>
> 
> 	        classes...
> 
> 	     </persistence-unit>
> 	</persistence>
>  	
>    4) I now do a jndi lookup for a staleless session bean and invoke a
> method to return the entity(s) persisted in step 1).
>       It does this happily.
> 
>    5) I then invove a method on the same SSB to insert another entity. CMP
> is used.
> 
>    6) I repeat step 4) and the entity applied in step 5) does not appear
> in the result list.
> 
>    7) I do have the following arg on my cammand
> line:-javaagent:{path}/openejb-javaagent-3.0.jar
> 
> 
> I've looked on the forum and tried various things. I'm beginning to think
> that I am overlooking something simple. Plse Help.
> 
> Using:
> Apache OpenEJB 3.1.1    build: 20090530-06:18
> EclipseLink 2.0.0
> hsqldb 1.8.0
> 
> Thnking you anticipation
> 
> Regards
> 
> Mike
> 

-- 
View this message in context: http://www.nabble.com/Embedded-OpenEJB-does-not-seem-to-be-flushing-to-the-DB-on-commit-tp25028791p25032699.html
Sent from the OpenEJB User mailing list archive at Nabble.com.