Hi,
I have two entity classes, for example Cathegory and Product. A Product belongs to a Cathegory and a Cathegory has many products. If I try to return some product or some cathegory from a web method, the entity manager tries to fetch all fields recursivelly and an infinite cycle error happens. I cand avoid that using the @XmlTransient annotation to avoid the cycle, but I would like to control this at method level (a method getCathegories() should return the cathegories with its products fetched, but not the cathegory of that products, and a method getProducts() should return the products with its cathegories fetched but not the products of that cathegories). How could I do this?
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116975#4116975
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116975
I'd like to run a couple of queries in the startup of the application.
The persistence context can be used only in session beans and message
driven beans. Any ideas how to invoke the persistence context or is
there any alternative approach to get hold of the persistence mechanism
upon startup?
Ideally I would like to have something like:
@Scope(ScopeType.APPLICATION)
@Startup
public class QueryStartup extends Jbpm {
@PersistenceContext
EntityManager em;
@Create
public void startup() {
Query q = "some query in here"
em.createQuery(q).getResultList();
}
}
Any suggestions?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116969#4116969
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116969