• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Entity EJB & data integrity problem

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is yet another ejbStore() call problem :
I have a CMP entity bean mapping a table. In my program it is created from a "wrapper" Session Bean that encapsulates data access. The session bean method has a TRANSACTION_READ_COMMITTED isolation setting. Then the method
goes on to create a related record
in another table that has a foreign key constraint to the "Entity" table,
using other classes (the Data Access Object Pattern).
The method fails throwing an SQLException saying the foreign key constraint is violated : in fact the Entity ejbStore() method is never called.
Actually, all my EJB methods (for session and entity beans) have a
TRANSACTION_READ_COMMITTED isolation setting because I previously ran into
an Oracle Serialization problem (the well-known ORA-08177 widely discussed
in other forums).
Generally, we use DAO classes to perform all "dependent" tables management,
the main table being mapped to an entity bean.
What transaction setting or strategy should I use to make this work ?
I'm using Weblo 5.1 SP 11 on NT
Thanks in advance.
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see two potential areas causing this problem.
As the container is free to cache database updates for performance, by using a method other than through the container to access a newly created instance maybe the underlying DB has not yet been updated. This could be from either the ejbStore() or ejbCreate() methods.
Also as 'The entity bean provider should use the ejbStore() method to update the instance using the accessor methods before its persistant state is synchronised.' (EJB specification) perhaps your server has taken this part of the contract to mean that you should be calling the ejbStore() method to synchronise rather than relying on its having done so.
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic