*
The moose likes Object Relational Mapping and the fly likes EJB findall method does not find persisted objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "EJB findall method does not find persisted objects" Watch "EJB findall method does not find persisted objects" New topic
Author

EJB findall method does not find persisted objects

Black Fox
Greenhorn

Joined: Dec 26, 2010
Posts: 7
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

Joined: Dec 26, 2010
Posts: 7
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

Joined: Oct 01, 2007
Posts: 553
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.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Are you loading it lazily?
Check this link


If you are not laughing at yourself, then you just didn't get the joke.
 
jQuery in Action, 2nd edition
 
subject: EJB findall method does not find persisted objects