• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

entity beans that don't persist?

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

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!

regards,
Simon
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roger,

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.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that the client, having obtained the entity bean�s home interface, failed to locate a reference to an entity object by using its primary key?
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you able to directly connect to the database ( using an SQL interface ) and able to see the record that is assumed to have been created by the appplication?

Herbert..
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Herbert,

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.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there is no decent tool for Cloudscape, then dump it. Try another DB, maybe MySQL, and you will be able to determine what records are being created by the entity bean.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, Roger. That's probably a good idea.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

regards,
Simon
 
reply
    Bookmark Topic Watch Topic
  • New Topic