File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Database synchronization with Entity Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Database synchronization with Entity Bean" Watch "Database synchronization with Entity Bean" New topic
Author

Database synchronization with Entity Bean

Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Dear all,
I am using JBOSS 3.2.3 with CMP.
Scenario :
Client side insert a new record(say, record A) through EJB CMP entity bean. Then, I login to the database table and delete that record A manually.
However, I found that the EJB CMP container doesn't synchronize with the database again. i.e. entity bean of record A is still there, although the record A has been deleted by me manually using database client software.
I know EJB CMP usually call ejbLoad() and ejbStore() to synchronize the database. It seems it doesn't call these method.
Do I need to config. the JBOSS CMP so that it can call these two methods regularly.

Thanks
Benson
David Koontz
Greenhorn

Joined: Oct 08, 2003
Posts: 14
My guess is that JBoss comes out of the box with what may be called "commit option A" (that's my guess). There are three options as to how a container may handle the CMP Entity commit: A, B or C, the vendor is free to choose.

Option A: Bean stays connected to EJBObject and assumed to be in sync.
(no ejbActivate & no ejbLoad)
Option B: Bean stays connected but not in sync.
( no ejbActivate - but ejbLoad will be called)
Option C: Bean is disconnected from EJBObject and goes back to pool.
(ejbActivate & ejbLoad are both called)

You can tune JBoss via .../conf/standardjboss.xml search for <commit-option>

One can experience this by getting an Entity bean then going behind the container's back and changing the DB tables directly (SQL) and then seeing if the Entity reflects the change (I suggest just a column update).

I'm trying to figure out how to do this (tune JBoss), how to figure out which option is current for a given Entity Bean/Deployment, etc.

So if you know - please help me out - thanks

David
Jeff Shelley
Ranch Hand

Joined: May 21, 2003
Posts: 70
Hi guys.

This set up per container configuration in standardjboss.xml. I think different types of beans use different commit options.

One cool thing you can do in your jboss.xml is define a container configuration that is SCOPED TO A SINGLE BEAN!!! I think that's pretty cool.

Check this out. It's mostly from their newly free docs.

<?xml version="1.0"?>
<jboss>
<enterprise-beans>
<session>
<ejb-name>EchoBean</ejb-name>
<configuration-name>The coolest Stateless SessionBean</configuration-name>
...
</session>
</enterprise-beans>


<container-configurations>
<container-configuration extends="Standard Stateless SessionBean">
<container-name>The coolect Stateless SessionBean</container-name>
<commit-option>D</commit-option>
</container-configuration>
</container-configurations>
</jboss>

anyway. picking D deviates from the spec, but it can do good stuff. Generally, B is what I've used, and I think that's what Standard CMP 2.x EntityBean defaults to.

Hope this helps!

--Jeff


It's almost Friday
Jeff Shelley
Ranch Hand

Joined: May 21, 2003
Posts: 70
of course....session beans don't have commit options. hahaha. but I was trying to point out that you can "extend" a configuration.
David Koontz
Greenhorn

Joined: Oct 08, 2003
Posts: 14
Jeff - what new _free_ docs are you refering to?

I've been looking for Jboss docs - there are hard to find, can you point me to them.

thanks!
David Koontz
Greenhorn

Joined: Oct 08, 2003
Posts: 14
perhaps I've found the free docs you've refered to:

One must be a registered "MemberPlus" of the JBOSS site: http://www.jboss.com/docs/index to have access to the html docs

They state in Chapter 5 http://docs.jboss.org/admin-devel/Chap5.html#0_51484


If an EJB does not provide a container configuration specification in the deployment unit ejb-jar, the container factory chooses a container configuration from the standardjboss.xml descriptor based on the type of the EJB. So, in reality there is an implicit configuration-name element for every type of EJB, and the mappings from the EJB type to default container configuration name are as follows:
  • container-managed persistence entity version 2.0 = Standard CMP 2.x EntityBean
  • container-managed persistence entity version 1.1 = Standard CMP EntityBean
  • bean-managed persistence entity = Standard BMP EntityBean
  • stateless session = Standard Stateless SessionBean
  • stateful session = Standard Stateful SessionBean
  • message driven = Standard Message Driven Bean



  • So that is the "default" mapping between a bean and the container type defined in .../conf/standardjboss.xml
    Jeff Shelley
    Ranch Hand

    Joined: May 21, 2003
    Posts: 70
    That's them. It's the html version of their admin guide that you used to have to buy.

    Have a good one!

    --Jeff
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Database synchronization with Entity Bean