Hello Group,

I have googled for this error and as far as I can see, the Appengine 
Datastore does not support more than 5 Groups in a transaction (at least in 
a XG Transaction).
OK ... but how do I get the the following issue done:

*1. I am using OpenSeccionInView Pattern. See my code below:*

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        
        //1. Create new EntityManager for this call
        EntityManager em = factory.createEntityManager();
        ThreadLocalEntityManager.set(em);    //==(1) Create EM

        em.getTransaction().begin();        //==(2) Begin Transaction
        try {
            chain.doFilter(request, response);
            em.getTransaction().commit();    //==(3) Commit Transaction
        
        } catch (ConstraintViolationException cve) {
            //This exception is thrown on Constraint Violation JSR303
            if(em.getTransaction().isActive()) {
                //This is usually never called
                em.getTransaction().rollback();
            }
        } catch (Exception e) {
            if(em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            e.printStackTrace();
        } finally {
            if(em.isOpen()) {
                em.close();                    //==(4) Close EM
            }
        }
    }

*2. I have Entities called JobCategory that stays in OneToMany relation 
with itself and OneToMany Relation with Job Entity
(JPA is used with DataNucleus)
*@Entity
public class JobCategory {
....
    @OneToMany(mappedBy = "mainCategory", cascade = CascadeType.ALL)
    @OrderBy("i18nKey ASC")
    private List<JobCategory> subCategories = new ArrayList<JobCategory>();
    
    @ManyToOne
    private JobCategory mainCategory;
    
    @OneToMany(mappedBy = "jobCategory")
    @OrderBy("creationDate DESC")
    private List<Job> jobs = new ArrayList<Job>();
...

    /**
     * Method will return All JobCategories that are available in the 
database
     */
    public static List<JobCategory> findAllJobCategories() {
        EntityManager em = ThreadLocalEntityManager.get();
            Query query = em.createQuery("SELECT e FROM " + 
JobCategory.class.getSimpleName() + " e  ORDER BY e.i18nKey");
        return (List<JobCategory>) query.getResultList();
    }
...
}

*My Question:*
I woudl like to load all JobCategories (there are more than 10 main 
JobCategories with 5-6 Subcategories each), but as mentioned the DB does 
not support more than 5 Groups per transaction.
The OSIV-Pattern, as shown in my code above and explained here: 
https://community.jboss.org/wiki/OpenSessionInView?_sscc=t ... opens one 
transaction for every DB-call which lets me get max 5 Grouped-Entities!? 

How do I get *all JobCategories* loaded properly!?
I assume that there is something wrong with my OSIV-Pattern since it allows 
only one transaction per call. But this is exactly what the JBOSS example 
did!?

Thank you in advance for your help!!

Nermin

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to