Logic repeating during page render
I have a page with a datatable, as far as I can tell, to reload the page after a commandLink is clicked, the logic is repeating.
Here is the BackingBean Logic
public List getAllRecords(){
try{
AccountDAO acctDAO = DAOFactory.getNewAccountInstance();
Iterator iter = acctDAO.findAll().iterator();
this.wrappedAccounts = ListManager.makeList();
while (iter.hasNext()){
this.wrappedAccounts.add(new WrappedAccount((AccountBean)iter.next()));
}
//return selectAll();
}catch (NullPointerException nps){
System.err.println(nps.toString());
}
System.out.println("***All Records***");
return this.wrappedAccounts;
}
public String toggleEdit(){
return"edit";
}
The dataTable is bound to the getAllRecords method of bean.
Here is the output from the server log.
2006-08-03 13:59:35,111 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
2006-08-03 13:59:35,111 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=402882a50cd5674b010cd5674c6f0000
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2006-08-03 13:59:35,111 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4729370931654656
2006-08-03 13:59:35,111 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2006-08-03 13:59:35,111 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2006-08-03 13:59:35,111 DEBUG [org.hibernate.transaction.JTATransaction] begin
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-08-03 13:59:35,111 DEBUG [org.hibernate.SQL] select accountbea0_.Acct_ID as Acct1_0_, accountbea0_.Acct_Num as Acct2_0_, accountbea0_.Acct_Name as Acct3_0_ from Budget.Account accountbea0_ order by accountbea0_.Acct_Num
2006-08-03 13:59:35,111 INFO [STDOUT] Hibernate: select accountbea0_.Acct_ID as Acct1_0_, accountbea0_.Acct_Num as Acct2_0_, accountbea0_.Acct_Name as Acct3_0_ from Budget.Account accountbea0_ order by accountbea0_.Acct_Num
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-08-03 13:59:35,111 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,111 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
2006-08-03 13:59:35,111 INFO [STDOUT] ***All Records***
2006-08-03 13:59:35,126 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
2006-08-03 13:59:35,126 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=402882a50cd5674b010cd5674c6f0000
2006-08-03 13:59:35,126 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2006-08-03 13:59:35,126 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4729370931716096
2006-08-03 13:59:35,126 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2006-08-03 13:59:35,126 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2006-08-03 13:59:35,126 DEBUG [org.hibernate.transaction.JTATransaction] begin
2006-08-03 13:59:35,126 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-08-03 13:59:35,126 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-08-03 13:59:35,126 DEBUG [org.hibernate.SQL] select accountbea0_.Acct_ID as Acct1_0_, accountbea0_.Acct_Num as Acct2_0_, accountbea0_.Acct_Name as Acct3_0_ from Budget.Account accountbea0_ order by accountbea0_.Acct_Num
2006-08-03 13:59:35,126 INFO [STDOUT] Hibernate: select accountbea0_.Acct_ID as Acct1_0_, accountbea0_.Acct_Num as Acct2_0_, accountbea0_.Acct_Name as Acct3_0_ from Budget.Account accountbea0_ order by accountbea0_.Acct_Num
2006-08-03 13:59:35,142 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-08-03 13:59:35,142 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-08-03 13:59:35,142 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-08-03 13:59:35,142 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#164]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#165]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#166]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#167]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#168]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.stlouiscity.budget.database.beans.AccountBean#307]
2006-08-03 13:59:35,142 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
2006-08-03 13:59:35,142 INFO [STDOUT] ***All Records***
As you can see the DAO logic is being performed twice between the button click and the page reloading. Any Idea why?

