Jim Talbut | 4 Jul 11:07 2015
Picon

Service returns object, but nothing is received unless toString is called!

Hi,

I have this class:
 <at> Transactional
 <at> Component
public class ProjectTransactionsImpl implements ProjectTransactions {

      <at> SuppressWarnings("constantname")
     private static final Logger logger = 
LoggerFactory.getLogger(ProjectTransactionsImpl.class);

      <at> Autowired
     private ProviderService providerService;

      <at> Override
     public Provider findProvider(String providerId) {
         Provider provider = providerService.find(providerId);
         logger.debug("Returning: {}", provider.getClass());
         return provider;
     }
}

And a unit test calling it like this:
 <at> RunWith(SpringJUnit4ClassRunner.class)
 <at> ContextConfiguration(locations = 
{"file:src/test/resources/testContext.xml"})
 <at> TransactionConfiguration(transactionManager = "transactionManager", 
defaultRollback = false)
public class MigrateProjects extends AbstractMigrationClass {

(Continue reading)

Henno Vermeulen | 2 Jul 13:36 2015
Picon

generated sql incorrectly uses inner join

I have a Department entity with two optional  <at> ManyToOne fields "faxLinkedTo" and "phoneNumberLinkedTo"
that optionally refer to another Department whose phone number of fax can be used.

I am writing a query to find out the names of departments that refer to either the fax or phone number of a given
department using the following JPQL:

SELECT d.name, d.faxLinkedTo.id, d.phoneNumberLinkedTo.id
FROM Department d
WHERE d.faxLinkedTo.id IN (:departments) OR d.faxLinkedTo IS NULL OR
               d.phoneNumberLinkedTo.id IN (:departments) OR d.phoneNumberLinkedTo IS NULL
ORDER BY d.name

As a test case I let department A link it's fax to department B by setting  A.faxLinkedTo = B, while having
A.phoneNumberLinkedTo = null.
When I run the query to find departments linking to department B, I expect it to return a row for A.

However I get an empty result because OpenJPA generates query with two inner joins and the
phoneNumberLinkedTo field is null.

I would expect the native query to use no joins at all and just do a simple select on the Department table.

Is this a bug or am I doing something wrong? Is there a way to let OpenJPA generate the correct query?

Or should I simply use two separate queries, one for faxLinkedTo and phoneNumberLinkedTo?

SELECT t0.NAME,
       t1.id,
       t2.id
FROM   dbo.crm_department t0
       INNER JOIN dbo.crm_department t1
(Continue reading)

zhourui | 1 Jul 15:29 2015
Picon

groupBy only return first row of resultSet

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
Root<Task> root = cq.from(Task.class);
Predicate p = cb.equal(root.get(Task_.person), person);
javax.persistence.criteria.Path<String> applicationNamePath =
root.get(Task_.applicationName);
Expression<Long> countPath = cb.count(applicationNamePath);
/*here is the problem*/
cq.multiselect(applicationNamePath,
countPath).where(p).groupBy(applicationNamePath);
for (Tuple o : em.createQuery(cq).getResultList()) {
	WrapOutCountApplication wrap = new WrapOutCountApplication();
	wrap.setApplicationName(o.get(applicationNamePath));
	wrap.setCount(o.get(countPath));
	list.add(wrap);
}

expect return mulit row,but it only return the first row.
is this a bug?

--
View this message in context: http://openjpa.208410.n2.nabble.com/groupBy-only-return-first-row-of-resultSet-tp7588359.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

patrice | 1 Jul 10:05 2015
Picon

Flush throws EntityExistsException

Hello,

Flush is throwing the following exception:

.<openjpa-2.3.0-r422266:1540826 fatal store error>
org.apache.openjpa.persistence.EntityExistsException: The transaction has
been rolled back.  See the nested exceptions for details on the errors that
occurred.
FailedObject: com.xxx.d2p106.jpa.entities.V06Studies <at> 2dfec3a1
                at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2370)
                at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java)
                at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2105)
                at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1876)
                at
org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:1045)
                at
org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
                at
com.xxx.d2p106.DatastoreUpserter.processSequence(DatastoreUpserter.java:443)

The code essentially looks like this:

                    dbTransaction = em.getTransaction();
		    dbTransaction.begin();

		    Query query = em.createNamedQuery("V06Studies.findByStudyCodeNcc");
(Continue reading)

Antoni Myłka | 29 Jun 11:59 2015

Expected an OptimistickLockException but got a SetRollbackOnlyException

Hi,

I have an issue whose cause lies somewhere between OpenJPA and Aries. Posting it here first, please
redirect me if it's the wrong place.

We use Open JPA in Karaf 3.0.2 (detailed bundle versions below). We have an DAO object, instantiated by
Blueprint with a jpa:context and a tx:transaction element. It gets the EntityManager from Aries JPA and
has a mandatory transaction on each method call.

<bean id="masterDataDao" depends-on="dataSource" class="some.package.MasterDataDaoImpl">
   <jpa:context unitname="masterDataDb" property="entityManager"/>
   <tx:transaction method="create,delete,find*,get*,update" value="Mandatory"/>
</bean>

That DAO object has CRUD methods for an entity class that uses optimistic locking. It has a long version
field annotated with  <at> Version.

Our problem appears when we get the optimistic lock error. We would expect our MasterDataDao.update
method to throw a TransactionRollbackException with an OptimisticLockException as its cause. Instead
it throws a TransactionRollbackException with a SetRollbackOnlyException as its cause (TransactionImpl.java:272).

The question is why? 

I tried debugging the issue. I put a breakpoint at
org.apache.geronimo.transaction.manager.TransactionImpl.markRollbackCause(java.lang.Throwable)
line: 539. AFAIU the problem is that that method is called *TWICE* when a transaction is processed. The
first time it is called with the "wrong" exception - SetRollbackOnlyException, the second time it's
called with the correct OptimisticLockException, but the correct exception isn't recorded in the
TransactionImpl object because the markRollbackCause method looks like this:

(Continue reading)

Mansour Al Akeel | 27 Jun 18:25 2015
Picon

Joining on unmapped Tables

In an OSGI environemnt, the JPA entities are distributed in different
OSGI Modules.
How do we query Entities in one Module, and join another entity in
different Module.

EclipleLink introduced an extention that allows using Table operator:
https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#TABLE

to solve this problem. Additional option is the composite Persistence Unit.

Do we have something similar to solve this problem in OpenJPA ?

How do others deal with this problem ?

Mihael Schmidt | 17 Jun 12:19 2015
Picon

OpenJPA dependency in osgi bundle with only data model classes

hi,

i have a question about openjpa. i got an osgi bundle with data models
containing jpa stuff. i have seen that the import-package line contains

org.apache.openjpa.enhance;version="[2.2,3)",org.apache.openjpa.util;version="[2.2,3)"
.

is it possible to have no package dependencies to openjpa as I am using
standard jpa stuff?

pom.xml: http://pastebin.com/wSvT03ca

Best Regards

Mihael Schmidt

--

-- 

Schulz Gebäudeservice GmbH & Co. KG
Dr.-Max-Ilgner-Straße 17
32339 Espelkamp
Persönlich haftende Gesellschafterin:
Gebäudereinigung Joachim Schulz
Verwaltungsgesellschaft mbH
Telefon: +49 5772 9100 0
Telefax: +49 5772 9100 11
Email: zentrale@...
Internet: www.sgbs.de
Geschäftsführer: Joachim und Dirk Schulz, Norbert Kosica
(Continue reading)

zhourui | 17 Jun 07:35 2015
Picon

group by error with empty table.

with the apache-openjpa-2.4.1-20150608.073929-5-binary.zip

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
Root<ReadCompleted> root = cq.from(ReadCompleted.class);
Predicate p = cb.equal(root.get(ReadCompleted_.person), person);
javax.persistence.criteria.Path<String> applicationNamePath =
root.get(ReadCompleted_.applicationName);
Expression<Long> countPath = cb.count(root);
cq.multiselect(countPath,
applicationNamePath).where(p).groupBy(applicationNamePath);

if the table of ReadCompleted is empty, it is error:

Caused by: com.ibm.db2.jcc.am.SqlException:
[jcc][t4][10120][10898][4.13.127] 操作无效:已关闭 result set。 ERRORCODE=-4470,
SQLSTATE=null
	at com.ibm.db2.jcc.am.id.a(id.java:661)
	at com.ibm.db2.jcc.am.id.a(id.java:60)
	at com.ibm.db2.jcc.am.id.a(id.java:103)
	at com.ibm.db2.jcc.am.bo.Db(bo.java:4599)
	at com.ibm.db2.jcc.am.bo.r(bo.java:4556)
	at com.ibm.db2.jcc.am.bo.f(bo.java:1399)
	at com.ibm.db2.jcc.am.bo.getObject(bo.java:1391)
	at
org.apache.commons.dbcp.DelegatingResultSet.getObject(DelegatingResultSet.java:325)
	at
org.apache.commons.dbcp.DelegatingResultSet.getObject(DelegatingResultSet.java:325)
	at
org.apache.openjpa.lib.jdbc.DelegatingResultSet.getObject(DelegatingResultSet.java:269)
(Continue reading)

Boehme, Richard | 8 Jun 21:52 2015

XML Mapping EOL

Is there any danger of XML mappings for JPA objects being phased out any time within the next 5 years (to pick a
timeframe), or not having features that the annotations have?

Thanks.
Richard

Pawel Veselov | 1 Jun 10:31 2015
Picon

Serp, JDK 1.8 and Lambdas

Hi.

I had some Lambda code in one of my entities, and the enhancement, using
2.2.2, failed with an exception. Is there a better version of Serp that I
can replace whatever comes stock in 2.2.2 (that's 1.14.1)?

Thank you,
  Pawel.

Exception in thread "main" java.lang.IllegalArgumentException: type = 18
at serp.bytecode.lowlevel.Entry.create(Entry.java:78)
at serp.bytecode.lowlevel.Entry.read(Entry.java:36)
at serp.bytecode.lowlevel.ConstantPool.read(ConstantPool.java:412)
at serp.bytecode.BCClass.read(BCClass.java:89)
at serp.bytecode.BCClass.read(BCClass.java:144)
at serp.bytecode.Project.loadClass(Project.java:139)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4884)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4831)
at org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4801)
at
org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:761)
at
org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:751)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4796)
at org.apache.openjpa.enhance.PCEnhancer.main(PCEnhancer.java:4787)
patrice | 26 May 15:45 2015
Picon

java.lang.Exception: Errors encountered while resolving metadata

Hello,

I am encountering the exception using openjpa 2.3, "java.lang.Exception:
Errors encountered while resolving metadata.  See nested exceptions for
details.", when invoking this code:

emf = Persistence.createEntityManagerFactory("d2pDatastoreUpserter_1.06PU",
puProps);
em = emf.createEntityManager();  
Query query = em.createNamedQuery("D2padmManagedCodes.findAll"); // this
raises the exception
...

I've turned on fine tracing everything looks good. For example for
"D2padmManagedCodes", I see this.

1729  d2pDatastoreUpserter_1.06PU  TRACE  [Root Thread] openjpa.MetaData -
Parsing query "D2padmManagedCodes.findAll".
1785  d2pDatastoreUpserter_1.06PU  TRACE  [Root Thread] openjpa.MetaData -
Processing registered persistence-capable class "class
com.novartis.d2p106.jpa.entities.D2padmManagedCodes".
1785  d2pDatastoreUpserter_1.06PU  TRACE  [Root Thread] openjpa.MetaData -
Loading metadata for "class
com.novartis.d2p106.jpa.entities.D2padmManagedCodes" under mode
"[META][QUERY]".
1785  d2pDatastoreUpserter_1.06PU  TRACE  [Root Thread] openjpa.MetaData -
Parsing class "com.novartis.d2p106.jpa.entities.D2padmManagedCodes".
1794  d2pDatastoreUpserter_1.06PU  TRACE  [Root Thread] openjpa.MetaData -
Set persistence-capable superclass of
"com.novartis.d2p106.jpa.entities.D2padmManagedCodes" to "null".
(Continue reading)


Gmane