Hallo, I have got a question regarding updates of JPA entities using Aries JPA with Declarative Services (DS). Hopefully, someone can help me.
Let's assume we have the Task entity from the example here: https://github.com/apache/aries/blob/trunk/jpa/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java When e.g. the fields "title" and "description" must be updated, is it mandatory to do it via JpaTemplate within a transaction like this: jpa.tx(em -> { task.setDescription("New description"); task.setTitle("New title"); em.flush(); }); or can safely be done without any transaction like this: task.setDescription("New description"); task.setTitle("New title"); I would say, it can be done directly without any transactions on application-level because transaction-type is "JTA" and not "RESOURCE_LOCAL". persistence.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" xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="treedb" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <!-- Only used when transaction-type=JTA --> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/treedb)</jta-data-source> <!-- Only used when transaction-type=RESOURCE_LOCAL --> <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/treedb)</non-jta-data-source> <class>...</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.H2Platform" /> <property name="eclipselink.weaving" value = "static"/> <property name="eclipselink.weaving.internal" value="true"/> <property name="eclipselink.weaving.lazy" value="true" /> <property name="eclipselink.weaving.changetracking" value="true" /> <property name="eclipselink.weaving.fetchgroups" value="true" /> <property name="eclipselink.weaving.eager" value="false" /> <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <property name="eclipselink.logging.level" value="FINEST" /> </properties> </persistence-unit> </persistence> Thank you very much. Regards, Jens
