• 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

CMP not reflecting the modified state during the transaction time

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I make use of a CMP bean which is used in a transaction.

Given below is the block of code that is executed...

helloWorld(int key) {
MusicListHome musicListHome = EJBHomeCache.getMusicListHomeHome();
MusicList musicList = musicListHome.findMusicListComposerOf(key);
if (key == 1) {
// update a record
}
/** the above updation is not reflected in CMP, when this helloWorld(key) method is called durng the second iteration of key */

if (key == 2) {
// do something
}
}


-
-
-
for (int key=0; key<5; key++) {
helloWorld(key);
// chnages made to CMP in first iteration is not reflected in second iteration of key
}
-
-
-

Any help will be appreciated. Please let me know, what other configuration information should I give to explain the problem better.

[ October 20, 2006: Message edited by: Kalyana Sundaram ]
[ October 20, 2006: Message edited by: Kalyana Sundaram ]
 
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is in the block
// update a record

MusicList represents 1 row in the database table?
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chu Tan:
What is in the block
// update a record




In the first iteration,
- I get the CMP bean representing the first row and do some process
- then I am updating one column, in the first row in a table (same table used by CMP) using JDBC statement.

In the next iteration,
- In the second iteration,- I get the CMP bean representing the second row. there is a finder method which returns the CMP bean representing the previous row. i.e, in this case, I can get the first row.
- Now the changes made during the first iteration to the first row using the JDBC statement, is not reflected in the CMP bean returned.

MusicList represents 1 row in the database table?



Yes MusicList represents one row in a table.

Any idea if what the problem is? How do I get the entity beans to get themselves updated if there is a change in the database.
[ October 20, 2006: Message edited by: Kalyana Sundaram ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2 questions. What application server are you using? Are you mixing entity beans with pure JDBC code within the same transaction?
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What application server are you using?
WebLogic 6.1 SP5
Are you mixing entity beans with pure JDBC code within the same transaction?
Yes

I face this situation when I am into fixing a bug in an already existing code base.
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's something you could try out use the delay-updates-until-end-of-tx element available within the persistence tag of the ejb-jar.xml. For details refer link.
Within the link refer the section "Using delay-updates-until-end-of-tx to Change ejbStore() Behavior"

I assume that you are using CMP entity beans and using datasource accessed via JNDI to retreive db connection.
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic