cancel
Showing results for 
Search instead for 
Did you mean: 

how the refresh the perstistance of an entitiy Bean

Former Member
0 Kudos

Hi,

I have an entity bean with CMP that works fine with the persistance to the database. when I delete some records of the used table of this bean with sql-studio the persistance layer only give me the view to table before the I did the delete. If this is normal on Ok put how can I force my bean to get the actual record of the table. Is there something like a refresh or synchronize of the persistance or entity bean.

Regards Bernd

Accepted Solutions (0)

Answers (1)

Answers (1)

SvetoManolov
Employee
Employee
0 Kudos

Hi Bernd,

the default isolation level of the CMP entity beans is Read Committed, i.e. a transaction using an entity bean will load entity's state from the database (which will be the last committed state) and will use this state till its (transaction's) end.

In order to get into the situation you are explaining it seems that you have a long running transaction which loads the entities state, then you delete the record from another transaction and the first one still does not see the effect of the removal.

So in order to see the removed entity a new transaction has to access it, e.g. execute a business method that starts a new transaction.

Regards,

Svetoslav

Former Member
0 Kudos

Hi Svetoslav,

I have a method "public Collection findMethodAll()" in my entiy bean. this mehtod is called from my session bean with:

	
public AuftragDTO[] GetAuftrag() {
	AuftragDTO[] result = new AuftragDTO[0];
         try {
	Collection col = auftragHome.findMethodAll();
        ...
        // copy col in  AuftragDTO[] ...
        ... 

When I understand you right the auftragHome.findMethodALL() has you run in an new transaction. How to do this ? Any sample avaiable ?

Regards Bernd

How can I start a new transaction ?

SvetoManolov
Employee
Employee
0 Kudos

Hi Bernd,

you should set "Requires New" transaction attribute for the findMethodAll of the entity bean or for the GetAuftrag method of the session bean.

Is the findMethodAll a finder method, i.e. do you have a EJB QL defined for it? If so, then it executes a query to the database, i.e. it should not see the removed entity and should not include it in the collection.

Regards,

Svetoslav

Former Member
0 Kudos

Hi Svetoslav,

I change the transaction attribut to "Requires New" and added some records to the databse via sql-studio.

I read the table via my session/entity bean and a jsp and again the new added record could are not in.

SvetoManolov
Employee
Employee
0 Kudos

Hi Bernd,

this is difficult to beleive.

1. Do you refresh the jsp page, i.e. execute the select statement after the update via the sql studio?

2. Is there something strange in the finder method - is it a standard finder method with defined EJB QL?

3. Does the EJB QL query really select all entities in the table? Could you give me the EJB QL string?

Regards,

Svetolsav