To get the modified rows from entity cache we have getEntityState() method at EntityImpl class.
Refer to my previous blog Accessing EO impl methods from VO impl where i am overriding the getEntityState() in EOimpl and calling it in VOImpl.
We can use methods written or overridden in VOImpl class to AMImpl class.
There are different states associated with an entity object.
STATUS_UNMODIFIED
STATUS_MODIFIED
STATUS_NEW
STATUS_DELETED
STATUS_DEAD
We have to check the state or row in our AmImpl class by using the VOImpl method and through this we can distinguish the rows present at vo.
Add below code in AMImpl class along with my previous post.
public void geCachedRowsCount(){
JobsVOImpl jobsVo = (JobsVOImpl)this.getJobsVO();
RowSetIterator iter = jobsVo.createRowSetIterator(null);
while(iter.hasNext()){
Row row = iter.next();
byte state = jobsVo.getEntityState(row);
System.out.println("Job_id -> "+row.getAttribute("JobId") +" and state ->"+state);
// use state variable to compare and write your logic
}
}
As you can see in above example, you will get the state of a row in above loop and you have to compare it with either
0 for new created row (but not committed to DB)
1 for unmodified state
2 modified state (but not committed to DB).
Refer to my previous blog Accessing EO impl methods from VO impl where i am overriding the getEntityState() in EOimpl and calling it in VOImpl.
We can use methods written or overridden in VOImpl class to AMImpl class.
There are different states associated with an entity object.
STATUS_UNMODIFIED
STATUS_MODIFIED
STATUS_NEW
STATUS_DELETED
STATUS_DEAD
We have to check the state or row in our AmImpl class by using the VOImpl method and through this we can distinguish the rows present at vo.
Add below code in AMImpl class along with my previous post.
public void geCachedRowsCount(){
JobsVOImpl jobsVo = (JobsVOImpl)this.getJobsVO();
RowSetIterator iter = jobsVo.createRowSetIterator(null);
while(iter.hasNext()){
Row row = iter.next();
byte state = jobsVo.getEntityState(row);
System.out.println("Job_id -> "+row.getAttribute("JobId") +" and state ->"+state);
// use state variable to compare and write your logic
}
}
As you can see in above example, you will get the state of a row in above loop and you have to compare it with either
0 for new created row (but not committed to DB)
1 for unmodified state
2 modified state (but not committed to DB).
Best M Tech Colleges in Noida
ReplyDeleteBest M Tech Colleges in Delhi
Best M Tech Colleges in Gurgaon
Best M Tech Colleges in UP
Best M Tech Colleges in India
Best M Tech Colleges in Hyderabad
Best M Tech Colleges in Bangalore
Best M Tech Colleges in Chennai
Mohegan Sun Pa Casino Review betway betway dafabet link dafabet link 601North Star Casino News, Photos and Videos - Shootercasino
ReplyDelete