File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP not reflecting the modified state during the transaction time

 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Justin Chu
Ranch Hand
Posts: 209
1
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Vinay Raj
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic