public StockAllot findById(String id, String company_id) { String userView = Person.tableName; StringBuffer sql = new StringBuffer( "select t.*,h.realname as head_name,c.realname as creater_name,u.realname as updater_name,dout.name out_depot_name,dto.name to_depot_name from "); sql.append(tableName); sql.append(" t left join "); sql.append(Depot.tableName); sql.append(" dout on dout.id=t.out_depot_id left join "); sql.append(Depot.tableName); sql.append(" dto on dto.id=t.to_depot_id left join "); sql.append(userView); sql.append(" c on c.id=t.creater_id left join "); sql.append(userView); sql.append(" u on u.id=t.updater_id left join "); sql.append(userView); sql.append(" h on h.id=t.head_id "); sql.append(" where t.company_id=? and t.id=? "); return dao.findFirst(sql.toString(), company_id, id); }