Spring JDBC provides a beanpropertyrowmapper implementation that automatically maps the fields that are read in a database table to the properties of a domain object
Be resolute with JdbcTemplate Ah, the next method
first injected into the DAO.
@Autowired
Public jdbctemplate JdbcTemplate;
and then in the Springappplication.xml configuration.
<!--JDBC Injection --
<bean id= "JdbcTemplate" class= "Org.springframework.jdbc.core.JdbcTemplate" >
<property name= "DataSource" >
<ref bean= "DataSource"/>
</property>
</bean>
then build a bean that fits your business
then write the DAO method
Java code
Public list<goodslistbean> findgoodslistbean (String goodsnum, integer vmid, integer omid, string rusjstart, string rusjend) throws exception { // if (Userid == null) { // return new Arraylist<pusmenu> (); // } Stringbuilder sbstr = new stringbuilder ( "Select g.*,u.name acceptancename,c.name companyname, Vm.name vmname " + " ,om.name omname,cc.name contactsname from goods g,pus_sys_user u,companyinfors c " + " ,variety_management vm,origin_ Management om ,companycontacts cc where g.acceptanceid=u.id " + " AND g.companyid=c.id AND g.vmid=vm.id AND g.omid=om.id " + " and g.contactsid=cc.id and g.state=1"); list<goodslistbean> list = jdbctemplate.query (Sbstr.toString (), new beanpropertyrowmapper (Goodslistbean.class)); return list; }
Finally, I'll just throw this list right into Easyui's rows.
Java code
List<goodslistbean> listg=new arraylist<goodslistbean> (); //list<goodslistbean> listgend=new arraylist<goodslistbean > (); try { listg=goodsdao.findgoodslistbean (Goodsnum, vmid, omid,rusjstart, rusjend); } catch (EXCEPTION&NBSP;E1) { // TODO Auto-generated catch block e1.printstacktrace (); logger.error ("Cargo query Exception", &NBSP;E1); listg=new arraylist<goodslistbean> (); } mapjson.put ( "Rows", &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;LISTG);
Spring MVC +jdbctemplate returns multiple table queries list<bean>