Discussion:
No Commit to DB on JSF - EJB - OpenJPA
faehne
2014-03-26 07:36:43 UTC
Permalink
Hi,

i'm doing some db-updates via OpenJPA, that are not written to DB (but TRACE
shows the sql-update and the commit).
Only on Server shutdown it will be written to DB.

The call-hierarchie is:
request-scoped jsfbean --> select entitybean --> ejb-call with enitybean as
param --> em.merge

Here are my code and config:

----------------------------------------
EJB:
----------------------------------------
@Stateless
public class UserServiceBean implements UserService {


@PersistenceContext(unitName="AmePersistenceUnit")
EntityManager entityManager;

...

@Override
public User update(User obj) {
System.out.println("===========================UPDATE
START=========================");
User usr = entityManager.merge(obj);
entityManager.flush();
System.out.println("===========================UPDATE
END=========================");
return usr;
}
...
}

----------------------------------------
perstistence.xml:
----------------------------------------

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

<persistence-unit name="AmePersistenceUnit" transaction-type="JTA">
<description>Persistence Unit fuer die AmeEnities</description>
<jta-data-source>DS</jta-data-source>


<class>xxx.User</class>
<properties>
<property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=TRACE,
Tool=TRACE, SQL=TRACE"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
</properties>

</persistence-unit>
</persistence>

----------------------------------------
managed bean (JSF):
----------------------------------------
public class Testing {

@EJB(name="...")
private AmeUserService userService;

public void test()
{
System.out.println("==================== START Testing
===================");

User user = users.get(0);
System.out.println(user.getName());
user.setVersuche(0);
user.setLoggedIn("J");
userService.update(user);

System.out.println("==================== STOP Testing
===================");
}
}




--
View this message in context: http://apache-geronimo.328035.n3.nabble.com/No-Commit-to-DB-on-JSF-EJB-OpenJPA-tp3987752.html
Sent from the Users mailing list archive at Nabble.com.
SergeyM
2014-04-09 08:45:07 UTC
Permalink
If you use an Oracle DataSource, you need to set config parameter id
DataSource:
<config-property-setting
name="CommitBeforeAutocommit">true</config-property-setting>



--
View this message in context: http://apache-geronimo.328035.n3.nabble.com/No-Commit-to-DB-on-JSF-EJB-OpenJPA-tp3987752p3987845.html
Sent from the Users mailing list archive at Nabble.com.

Loading...