When I tired to override two columns
fieldValue[0].setIdentifier("0");
fieldValue[0].setName("FirstDate");
fieldValue[0].setValue(updated_FirstDate);
fieldValue[0].setIdentifier("1");
fieldValue[0].setName("SecondDate");
fieldValue[0].setValue(updated_ SecondDate);
cAPIClient.addActivityWithOverride(somenumber, “some value”,fieldValue);
addActivityWithOverride() method 3 parameter is type of FieldValue, When I tried with HashMap, type cast exception is comming.
but my first name and value is overriding/replacing by second value, here how can I initialize the FieldValue with value more than 1 so that I can generate Activity With Override.
Please help.
Last edited by java_dev; September 29th, 2009 at 05:58 AM.
And with good reason.
length is a property that primitive array types provide, as a convenience for polling the size of the array. It can only be read from.
Code:
FieldValue [] fieldValues = new FieldValue[5];
System.out.println(fieldValues.length);
here spring is injecting the FieldValue bean, do we need new keyword again ? all I want is how to assign size. please correct me if am wrong.
In the constructor, or @PostConstruct annotation you should provide initialization of this array. This assumes you know the size you need in advance, and it is fixed.
You have only provided a container to hold these objects, but it does not contain the reference objects yet, so you still have to do
Code:
fieldValues[0] = new FieldValue();
------
If you are satisfied with the responses, add to the user's rep!
The array capacity has to be instantiated or given to you (assuming you know this in advance).
Is this your implementation of the class? Can you switch this to LinkedList<FieldValue> instead that is wired to you? It's unclear what you are doing or plan to do , but an array class that has to be dynamically created for me isn't an ideal candidate to be wired up by Spring.
You have two things you must do:
1) Instantiate the array
2) Instantiate the objects, and provide the reference object to the desired index.
It's hard to give you more info without knowing what/why you are doing it this way, and whether or not you manage the code behind FieldValue.
------
If you are satisfied with the responses, add to the user's rep!
public void setICListDAO(ICNumberListDAO cListDAO) {
this.cListDAO = cListDAO;
}
public void runScheduledJob() {
List result_list = cListDAO.getAllCPublicIDs();
.
.
.
}
ICNumberListDAO.java
Code:
public interface ICNumberListDAO extends IJdbcDAO {
List getAllCPublicIDs();
// other methods
}
CCCListDAO.java
Code:
public class CCCListDAO extends JdbcDAO implements ICNumberListDAO {
public List getAllCPublicIDs() {
List result_list=null ;
try{
result_list = getJdbcTemplate().queryForList(
this.loadQuery(SQLConstants.PACKAGE,
SQLConstants.C_LIST));
} catch (Exception bse) {
logError("Error in querying.", bse);
}
return result_list;
}
}
CActivityGenerationScheduledJobTestCase.java
Code:
public class CActivityGenerationScheduledJobTestCase extends
AbstractTestCase {
public void testRunScheduledJob() {
cActivityGenerationScheduledJob.setICListDAO(cListDAO);
cActivityGenerationScheduledJob.setICAPIClient(iCAPIClient);
try {
cActivityGenerationScheduledJob.runScheduledJob();
} catch (Exception e) {
logError("Error running runScheduledJob.", e);
fail();
}
}
when I called runScheduledJob() from CActivityGenerationScheduledJobTestCase class I am getting following exception. Please tell me the best solution for this.
(I have observed CCCListDAO class is coming as null)
Error:
HTML Code:
2009-10-26 06:21:58,772 ERROR Error in Generating Activity.
java.lang.NullPointerException
at com……CActivityGenerationScheduledJob.runScheduledJob(CActivityGenerationScheduledJob.java:61)
at com……CActivityGenerationScheduledJobTestCase.testRunScheduledJob(CActivityGenerationScheduledJobTestCase.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Bookmarks