I have created a remote entity bean, which I access through a simple client which looks up the bean, gets the home, narrows it and passes some database fields to the ejbCreate. So, I create a few beans (rows in my database) and then access them with another simple client, which simply picks up a primary key from the command line and does a findByPrimaryKey(String key) and then prints out the fields of the bean. This works fine so long as I am in the same session where I created the beans. If I stop the server and restart, using one of the keys, I get an ObjectNotFoundException. I thought that these entity beans were supposed to be persistant! If the row exists in the database, then I should be able to get my bean back. Is there something I am forgetting? I am using the RI and Cloudscape database i.e. the defaults. Any ideas would be most welcome!
Even though an entity survives a server crash, this does not mean that this is transparent to the client which may have to re-establish the home and component interfaces. In other words, the references which the client is holding are all re-establishable as long as the entity is still in the database.
Yes, that's what I mean. When the entity beans are created, I assume the corresponding columns are created in the database. There was no server crash. I simply stopped the server and then restarted it. I was expecting that since the row exists in the database, my findByPrimaryKey method should send back a stub to the bean representing this row. I am most surprised to be loosing data.
Yes, that's exactly what I am saying. I run the client and print at each step in the process. I get the home and when I execute findByPrimaryKey I get javax.ejb.ObjectNotFoundException: no database row for primary key. I am using the same key I used in my ejbCreate and this step did create a bean which I have previously interrogated. Everything gets lost when I stop and restart the server. [ May 23, 2005: Message edited by: Simon Ingram ]
I tried. The database is Cloudscape and there is an sql enquiry tool called the ij tool. It is featured in the J2EE documentation and suggests a link to IBM for more information. Unfortunately there is no information on the web site and the tool is old and bad. You cannot do strandard sql enquiries, for example
gives a syntax error! I did however manage to confirm that at least one of my records was in Cloudscape and I could enquire on it, but after a while this record just disappeared from the database!
I can enter more beans then enquire on them and then they too disappear. It is as though the beans are garbage collected and leave no trace in the database.
Apologies! It was a programming error on my side. I was trying to reestablish the primary key in ejbActivate!
So, cloudscape does persist data (no real surprise) but when one encounters errors during development the ij tool provided is very poor. One cannot run proper sql queries on the database. No matter how good cloudscape may be, this fact is enough to deter one from using it. A shame for IBM.