*
The moose likes EJB and other Java EE Technologies and the fly likes CMP not reflecting the modified state during the transaction time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP not reflecting the modified state during the transaction time" Watch "CMP not reflecting the modified state during the transaction time" New topic
Author

CMP not reflecting the modified state during the transaction time

Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
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 ]

Only those who will risk going too far can possibly find out how far one can go !!!
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
What is in the block
// update a record

MusicList represents 1 row in the database table?
Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
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

Joined: Jun 19, 2006
Posts: 81
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

Joined: Mar 18, 2005
Posts: 94
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

Joined: Jun 19, 2006
Posts: 81
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMP not reflecting the modified state during the transaction time