AnsweredAssumed Answered

Cant store data in custom database table

Question asked by alihammad on Dec 3, 2009
I am extending Alfresco and created a table in database, i want to do view/add/edit/delete operations on that table. For that I created a jsp and showed the table data in a datatable JSF component.

Secondly, I have two input fields and a Save (submit) command button. This button calls a method saveLookupItem of LookupTable Bean. Here is the command button with two input fields.


<h:panelGrid border="0" columns="2">
                                                                        <h:inputText id="inputKey" value="#{LookupTable.lookupKey}"  />
                           <h:inputText id="inputValue" value="#{LookupTable.lookupValue}"  />
                           <h:commandButton value="Save" action="#{LookupTable.saveLookupItem}"/>
                        </h:panelGrid>

When command button is pressed, following method is called successfully.

public String saveLookupItem() {
      String status = "failure";
                —- some code —–
      
      LookupTableDao lookupTableDao = (LookupTableDao) ServiceFinder
            .findBean("lookupTableDAOImpl");

           lookupTableDao.save(lookupTablePojo);
                —- some code —–   
   }


This above method eventually calls the save method of A DAO lookupTableDao which is as follows


public void save(LookupTablePojo obj) {
      log.debug("saving LookupTableDao instance");
      try {
         getHibernateTemplate().save(obj);
         log.debug("save successful");
      } catch (RuntimeException re) {
         log.error("save failed", re);
         throw re;
      }
   }

This save method runs without any error but does not save any value. On the other hand methods that fetch data from db table like "findAll" and "findById" work fine. Please suggest what can I do to insert/save data.

JSF Managed bean


<managed-bean>
       <managed-bean-name>LookupTable</managed-bean-name>
       <managed-bean-class>com.lookuptables.web.ui.LookupTable</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>   
    </managed-bean>

spring bean which is defined in application-context.xml


<bean id="lookupTableDAOImpl" class="com.lookuptables.dao.LookupTableDaoImpl">
      <property name="sessionFactory">
         <ref bean="sessionFactory"/>
      </property>
</bean>

Outcomes