zhourui | 14 May 05:37 2015

criteria count error.

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createTupleQuery();
Root<Attachment> root = cq.from(Attachment.class);
javax.persistence.criteria.Path<String> personPath =
Predicate p = cb.isMember(share, root.get(Attachment_.shareList));
cq.multiselect(personPath, cb.count(root)).where(p).groupBy(personPath);
List<WrapOutShare> list = new ArrayList<>();
for (Tuple o : em.createQuery(cq).getResultList()) {
	WrapOutShare wrap = new WrapOutShare(o.get(personPath), 0L);

with cb.count(root), it will throw exception;

without cb.count(root), it is work fine!

is this is a bug?

7538  null.s001  TRACE  [http-apr-8080-exec-147] openjpa.jdbc.SQL - <t
1841362512, conn 1213857262> executing prepstmnt 1134522538 
        t0.ID = t1.ATTACHMENT_ID 
7539  null.s001  TRACE  [http-apr-8080-exec-147] openjpa.jdbc.SQL - <t
1841362512, conn 1213857262> [1 ms] spent
7549  null.s001  TRACE  [http-apr-8080-exec-147] openjpa.jdbc.JDBC - <t
1841362512, conn 0> [0 ms] close
(Continue reading)

Johannes Martin | 11 May 08:06 2015

SchemaTool reflect failes to discover foreign keys


I'm trying to extract schema information from an existing oracle
database. Running "SchemaTool -reflect" does the job correctly for the
tables in question, except it does not record the foreign keys or the
tables in the generated schema file.

might imply that the default DynamicSchemaFactory does not extract
foreign key constraints from the database, I tried to enable the
LazySchemaFactory with ForeignKeys set to true, but this does not change
anything either.

What am I doing wrong? Am I possible specifying the SchemaFactory
property in the wrong place? My persistance.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
  <persistence-unit name="openjpa">

      <property name="openjpa.jdbc.DBDictionary"
      <property name="openjpa.jdbc.SchemaFactory"
(Continue reading)

zhourui | 27 Apr 15:31 2015

how to use orderBy clause in tuple query?

[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R
<openjpa-2.2.3-SNAPSHOT-r422266:1595313 nonfatal user error>
setResult() 子句中选择此数据。请将此排序数据包含在 setResult()
中,以便 OpenJPA 可以抽取此数据以进行内存中排序。
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
(Continue reading)

Marco de Booij | 26 Apr 17:57 2015

Mapping a Join Table with Additional Columns

I use Tomee 1.7.1 with openjpa version 

I have an entity auteurs and an entity boek. They have a ManyToMany 
relation through the entity auteurs_boeken. In this entity there is a 
field type to define the type of the relation (writer, illustrations, 
...). I followed the 
https://en.wikibooks.org/wiki/Java_Persistence/ManyToMany page and came 
up with the following classes (left out all constructors, getters, and 

 <at> Entity
 <at> Table(name="AUTEURS", schema="BYBLOS")
public class AuteurDto
     extends Dto implements Comparable<AuteurDto>, Cloneable {
   private static final  long  serialVersionUID  = 1L;

    <at> Id
    <at> GeneratedValue(strategy=GenerationType.IDENTITY)
    <at> Column(name="AUTEUR_ID", nullable=false, unique=true)
   private Long    auteurId;
    <at> Column(name="NAAM", length=100, nullable=false)
   private String  naam;
    <at> Column(name="VOORNAAM", length=100)
   private String  voornaam;

    <at> OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, 
   private List<AuteurBoekDto> boeken;
(Continue reading)

Henno Vermeulen | 23 Apr 11:48 2015

criteria API generates a parameter for literal in group by but does not provide the value


I have a query created using the criteria API where I group by an expression that contains a small
calculation using literal values.

OpenJPA generates the correct SQL but does not provide the value of the generated parameter in the group by
clause. The query fails with a SQL exception "The value is not set for the parameter number 9.".

I can reproduce the issue with a minimal example. Suppose we have a person class with integer age and length
columns and we wish to select the average length grouped by the person's age / 10:

                        CriteriaBuilder cb = em.getCriteriaBuilder();
                        CriteriaQuery<Double> query = cb.createQuery(Double.class);
                        Root<Person> person = query.from(Person.class);

                        Expression<Double> averageLength = cb.avg(person.<Integer> get("length"));
                        CriteriaQuery<Double> select = query.select(averageLength);

                        select.groupBy(cb.quot(person.<Integer> get("age"), cb.literal(10)));
                        // optional where, useful to ensure parameters are logged
                        select.where(cb.gt(person.<Integer> get("age"), cb.literal(20)));

                        System.out.println("result: " + em.createQuery(query).getResultList());

Whe running this query with trace and displaying parameters on I get:

1067  testPU  TRACE  [main] openjpa.Query - Executing query: Query:
org.apache.openjpa.kernel.QueryImpl <at> be4f81; candidate class: class entities.Person; query: null
1108  testPU  TRACE  [main] openjpa.jdbc.SQL - <t 5763249, conn 7326702> executing prepstmnt 26531336
SELECT AVG(t0.length) FROM Person t0 WHERE (t0.age > ?) GROUP BY (t0.age / ?) [params=(int) 20]
(Continue reading)

Mark Struberg | 19 Apr 17:03 2015

[VOTE] Release Apache OpenJPA-2.4.0

It’s a great pleasure to call a VOTE for releasing Apache OpenJPA-2.4.0.

OpenJPA-2.4.0 implements the JPA-2.0 specification.

The staging repository can be found here:

The Release Notes can be found in the file openjpa-project/RELEASE_NOTES.html and online under:

The SVN source TAG is (1674626):

The source release can be found here:

The binary release is here:

My Key can be found here 

The VOTE will be open for 72 hours.
[+1] approve
[+0] meh, don’t care
[-1] stop, I’ve found a ${fish} in there

txs and LieGrue,
your OpenJPA team
(Continue reading)

Rashmi Maheshwari | 15 Apr 13:02 2015


Hi friends,

I am facing issue listed on below link.

I want to reproduce the issue. Please suggest in what scenarios this type of exception comes.

ATTENTION: This e-mail may contain confidential information that is intended solely for the addressee.
If you are not the intended recipient, you should delete this message and are hereby notified that any
disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.
Raimund Klein | 14 Apr 13:30 2015

Occasional IllegalArgumentException (Illegal Capacity) inside ManagedCache

Hi all,


We are using OpenJPA 2.2.0 as part of our JBoss Fuse installation. Every couple of months we run into a stack trace such as this one:


Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Illegal Capacity: -12
at org.apache.openjpa.kernel.BrokerImpl.detachAll(BrokerImpl.java:3407)
at org.apache.openjpa.kernel.DelegatingBroker.detachAll(DelegatingBroker.java:1206)
at org.apache.openjpa.persistence.EntityManagerImpl.clear(EntityManagerImpl.java:1169)
at org.apache.aries.jpa.container.impl.EntityManagerWrapper.clear(EntityManagerWrapper.java:49)
at org.apache.aries.jpa.container.context.transaction.impl.SynchronizedEntityManagerWrapper.clear(SynchronizedEntityManagerWrapper.java:113)
at org.apache.aries.jpa.container.context.transaction.impl.JTAEntityManager.createNamedQuery(JTAEntityManager.java:315)

... 90 more
Caused by: java.lang.IllegalArgumentException: Illegal Capacity: -12
at java.util.ArrayList.<init>(ArrayList.java:142)[:1.7.0_55]
at org.apache.openjpa.kernel.ManagedCache.copy(ManagedCache.java:259)
at org.apache.openjpa.kernel.BrokerImpl.getManagedStates(BrokerImpl.java:4054)
at org.apache.openjpa.kernel.BrokerImpl.detachAllInternal(BrokerImpl.java:3418)
at org.apache.openjpa.kernel.BrokerImpl.detachAll(BrokerImpl.java:3403)
... 101 more


Once this has occurred, the only way to recovery is a platform restart.


Our impression is that this is a multithreading issue inside OpenJPA. Hoping for the best, we’ve upgraded to 2.2.2 just now and will test with this one, but I’d just like to know if anyone has encountered this before and maybe can help us with an idea what’s going here? We scanned the recent release notes, but haven’t found anything like this mentioned.



Kind regards


Raimund Klein
Technical Architect

t. +44 (0)203 657 0481




This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying, disclosure or taking of any action in reliance upon it by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. Monitise accepts no liability if this email harms any systems or data of the recipient (including as a result of software virus infection or where this e-mail is modified or amended in any way during or following transmission) or if this email is accessed by anyone other than the person(s) to whom it is addressed.

The Monitise group includes Monitise plc (Reg. No. 6011822), Monitise Group Limited (Reg. No. 5590897), Monitise International Limited (Reg. No. 5556711), Monitise Europe Limited (Reg. No. 4831976) and Mobile Money Network Limited (Reg. No. 7153130). These companies are registered in England and Wales and their registered office address is 95 Gresham Street, London, EC2V 7NA United Kingdom.

This email message has been delivered safely and archived online by Mimecast.
For more information please visit http://www.mimecast.com
David Goodenough | 6 Apr 11:15 2015

Which version of JPA (2.0 or 2.1) does openjpa 2.4 support?

According to:-


openjpa 2.4 is the release that should implement JPA 2.1.  But I am told
on the tomee mailing list that although tomee 2.0 included an
openjpa 2.4 snapshot it does not support jpa 2.1.

I am confused, can someone enlighten me.


Hal Hildebrand | 28 Mar 00:28 2015

OpenJPA PostgreSQL UUID column

Attachment (UuidValueHandler.java): application/octet-stream, 2111 bytes

I’m trying to use the native UUID type for PostgreSQL in my OpenJPA model.  I’m using OpenJPA 2.3.0 and at the current level of the PostgreSQL JDBC driver.

I’ve tried to accomplish this several times and I’ve gotten a bit further this time.  I created a ValueHolder (see attached file) and it does what I believe is the correct setup for this type.  I use this as the strategy for the column - i.e. :

<at> Strategy("com.chiralbehaviors.CoRE.openjpa.UuidValueHandler")

I’ve validated via breakpoint that the UuidValueHolder is indeed called in setup and when converting values.  I’m at the point of trying to do an insert, and regardless of whether I use an actual UUID as the return mapping (i.e. no transform) or a string (UUID.toString()) I get the same error:

ERROR: column "id" is of type uuid but expression is of type bytea
  Hint: You will need to rewrite or cast the expression.
  Position: 93 {prepstmnt 1848199707 
INSERT INTO ruleform.agency (id, notes, update_date, description, name, 
    VALUES (?, ?, ?, ?, ?, ?) 
[params=(byte[]) [B <at> 9ac8b5b, (null) null, (Timestamp) 2015-03-27 15:20:05.921, (null) null, (String) CoRE, (byte[]) [B <at> 15b17c95]} [code=0, state=42804]

I believe that this error comes from the postgres jdbc driver, not openJPA.  I’ve even tried using PGObject, which surprisingly works just fine, but throws the same error.

In my google searches, this has come across as a typical problem, and I’ve only found solutions for this (hypothesized) for Toplink and Hibernate.  The one thing I could find suggested writing the ValueHolder and that does work up until the point I try to actually insert in JDBC land.

Note that the UUID is being passed as a byte array.

So my question is, am I doing anything incorrect?  Missing something?  From the error message, it would appear postgresql wants me to cast the result, but I’m not sure how to accomplish that in OpenJPA.  It could simply be a red herring.

Any help appreciated, as I simply can’t find a working solution via Der Google

sia | 17 Mar 23:55 2015

Forcing an outer join in many-to-one relations with order by column

Hello All:

I was wondering if someone can help me with this issue. I have been reading/searching the forum with no avail
as well all over the web. I have an entity as follows:

 <at> Entity
 <at> Table(name = "REQUEST")
public class Request {

 <at> ManyToOne(fetch = FetchType.EAGER)
     <at> JoinColumn(name = "SLOT_ID", referencedColumnName = "SLOT_ID")
    private Asset slot;


Running the following query cause a left outer join with my relation : 

Select r from Request r;

However; if I run

Select r from Request r ORDER BY r.slot.name

this would generate an inner join.

I would like to force an outer join at all times at the entity level. I have looked into writing a custom
strategy by extending RelationFieldStrategy; however, I see only addFetchInnerJoin in
JDBCFetchConfiguration class when I try to override

public void selectEagerJoin(Select sel, OpenJPAStateManager sm,
                            JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)

Can someone kindly give me a hint if this is possible or I have to extend a different class or some how set the
fetch mode to OUTER JOIN in my entity.