Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB findall method does not find persisted objects

 
Black Fox
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

This is a very frustrating problem for me and I don't know which information may be specifically relevant, so if you need any additional information please tell me.

The situation is that I have stateless EJB facades defined in different servlets. I use one of these facades to persist objects into my datasource (mysql) with no problem, but then the other EJB facades' findall method does not retrieve the newly persisted objects. What's strange is that new data only becomes available after I recompile and redeploy using NetBeans' debug configuration. The facade that was used to persist the objects, however, seems to be able to find them too.. By the way, all the session and entity beans were generated by NetBeans.

I am by all means lost, so any help would be greatly appreciated!

This here is the method in my QuotaFacade session bean that I use to persist new Quota objects based on information from an HTML Form. The instance of the Session Bean object that has this method invoked resides in a servlet that handles form requests.



To give some brief information about the data structure, Faculties have Departments, which in turn have associated Quotas. However, when I create
in the servlet responsible for doing this, I see when debugging that newly persisted Quotas are not included - despite the fact that they have already been inserted into the datastore.
 
Black Fox
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just figured out how to enable sql logging on glassfish (I am not very knowledgeble in the area). The problem seems to be that the .findAll() method of the EJB's seem to be executing queries only once. The output below shows the queries executed the first time the .findAll() methods are called. The next time around nothing gets added to the logs.

 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include the definition of the findAll query and the code used to execute it.

Does the findAll return an empty collection?

It could be that you are not committing your transaction, or are using a different database or schema. Check (and include) your persistence.xml.
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you loading it lazily?
Check this link
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic