Using CriteriaContainer with EclipseLink 2.3.1

I am having a tough time showing my class data in a table using the CriteriaContainer addon. In the code below, i create the CriteriaQueryDefinition but it seems as it cannot find my DB details from the created persitence-unit.

Defining the EMF

 @PersistenceUnit(unitName = "persistenceUnit")
	private EntityManagerFactory factory;

public CourseEntityContainer(){
factory = Persistence.createEntityManagerFactory(“persistenceUnit”);
entityManager = factory.createEntityManager();



  public CriteriaContainer<Course> createCourseContainer() {
            // the default query definition gives us all the entities and respects
            // container filtering and sorting with nothing else to do.
            qd = new CriteriaQueryDefinition<Course>(entityManager,true,100,Course.class);              
            CriteriaContainer<Course> courseContainer = new CriteriaContainer<Course>(qd);

            return courseContainer;

Can you elaborate? Do you get an error message? an empty container?

Something just clicked: you need a more recent version of EclipseLink – from the Release Notes:

  • Tested under Hibernate 3.6.6.Final and EclipseLink 2.4.0-SNAPSHOT. You need an EclipseLink more
    recent than August 17, 2011 – there was a bug in multiselect() prior to that date that will likely
    prevent you from using this add-on with EclipseLink. See also notes for release 0.6.0 in the
    doc/releaseNotes.txt file.

I only get an error when i try to reference the container by for example checking its size. The error i get does state that multiselect is not allowed. I tried downloading the EclipseLink 2.4.0-SNAPSHOT but my build fails saying that “2.4.0 verision of eclipselink does not exist”. Could you show the dependency maven example for this.


is what I had in my pom.xml last time I checked (took this from the committed source for the criteriaapp_test application under google code, don’t have access to my dev machine right now). EclipseLink is currently at 2.4.0-M18 according to their download pages, unfortunately there doesn’t appear to be an easy way to browse their Maven repository.

I confirm that 2.4.0-SNAPSHOT exists (I have an Artifactory set up to do caching, and it picked up an update this morning)

I just downloaded the latest (2.4.0-SNAPSHOT) and tried showing the size of the container and this is the error i keep getting.

System.out.println("CriteriaContainer<> has " + courseContainer.size()+" items.\n");
java.lang.IllegalArgumentException: multiSelect was invoked on a CriteriaQuery with a primitive result type.  Either the return type is incorrect or select should be used instead.

That is exactly the issue that releases 0.6.0 and 0.9.0 were meant to fix. So this is rather puzzling, and could be a regression (as in “version control update and merge swallowed the fix”). I’ll have to look into this, but won’t have time in the next few days due to family events. You’re quite welcome to poke at the source code meanwhile.

Another idea would be to try with releases 0.9.0 (just in case)

Just as a note, i am using the eclipse-link-container-2009-11-25.jar . Is this the correct version of the container?

There is no such file in the CriteriaContainer distribution, and I wrote it in 2011, not 2009. What are you expecting that file to provide ?

Could you show me were the example projects pom.xml file is and maybe i can take a look at the versions of these files and try to figure out whats happening. I apologize for that last post that was a different container i had tried to use specifically made for EclipseLink but it fails terribly. If the fix was done in 0.6 or 0.9, what is the latest version of the criteriacontainer or does this have nothing to do with the criteriacontainer?

I will aplogize again as i went and found that i was using the old version of your prestigious:D container (0.4.2). After fixing this and updating i am able to avoid this failure. If you could please show me how to now add my table columns and data using this container that would be great.

On the addon page
on the right hand side you will see a link for “Source code for sample app” that will lead you to
the source code for the sample app
. By the way, you will also see a link to the Maven POM at the top, and a download link to get the javadoc, sources and jar if you don’t use Maven.

If you want to see the pom.xml for the sample application, once you have found the source code as described above, you can look at the left for the files in the repository. Clicking on criteriaapp_test will show you the test app top level. You will then see the pom.xml at the right.

With respect to adding columns, there is nothing to do. By default, all columns are selected. Looking at the examples in criteriaapp_test and at the
is the best way to figure things out.