• Welcome to KonaKart Community Forum. Please login or sign up.
 

Getting details from Database

Started by anujbatra2788, October 28, 2012, 07:45:42 pm

Previous topic - Next topic

anujbatra2788

Hi,

I am trying to fetch details of a manufacturer from Database but I am getting an error

java.lang.ClassCastException: com.konakart.om.Manufacturers cannot be cast to com.workingdogs.village.Record

My code is

                KKCriteria manufacturerCriteria = new KKCriteria(Torque.getDefaultDB());
      manufacturerCriteria.add(ManufacturersPeer.CUSTOM3, manufacturer.getManufacturerCode());
      List<Record> manufacturers = ManufacturersPeer.doSelect(manufacturerCriteria);
      
      if(manufacturers.size() > 0) {
         Record manufacture = manufacturers.get(0); Getting error at this line.
         manufacturerCriteria.clear();
         return manufacture.getValue(ManufacturersPeer.MANUFACTURERS_ID).asInt();
      } else {
         manufacturerCriteria.clear();
         return -1;
      }

Can you please help me out

ming

Yes that's not a valid cast.

You should use the APIs wherever possible.  Check the KKEngIf interface in the javadoc - if you've installed KonaKart you can see the javadoc at http://localhost:8780/javadoc/

eg.. http://localhost:8780/javadoc/server/com/konakart/appif/KKEngIf.html

ming

About the javadoc....

The advantage of going to localhost to view it is that it's more likely to match the version you are currently using and that it's local.

However, the javadoc for the latest public release is also available online at:

http://www.konakart.com/documentation/javadoc


anujbatra2788

I tried having a look into the javadoc. However I want to get the manufacturer based on a custom field and not by name or id. I could not find any method in KKAdminEng. Also is there any programming guide other than the user guide for Konakart ?

Secondly, I am trying to create jobs in konakart. Is it possible to run jobs thorough command line rather than using quartz. Quartz is a good job scheduling mechanism but has an disadvantage over monitoring. Also are there any examples for jobs in Konakart distribution.

Sorry for asking too many things in a single go :D

ming

We have added a much more flexible Manufacturer search API in the next version (out early in the New Year).

For now, you could try something like this to retrieve Manufacturers and instantiate Manufacturer objects:

        List<Record> rows = BasePeer.doSelect(c);   // c is the Criteria object
        Manufacturer[] retArray = new Manufacturer[rows.size()];

        int i = 0;
        for (Iterator<Record> iter = rows.iterator(); iter.hasNext();)
        {
            Record row = iter.next();
            Manufacturer m = new Manufacturer(row, c);    // c is the Criteria object
            retArray[i++] = m;
        }



We provide some utilities and examples for running KonaKart-related batch jobs in Quartz - in our Enterprise version.