Hi all,
I get a 'java.lang.ClassCastException: java.lang.String' when i use a
criteria with a diffenrent class-Type.
Do i have to use the same class-type as discribed in the repository-file?
-> this function works fine!
----------------------
public static Iterator getAllPrj (PersistenceBroker _broker, Integer
_iProjectFilter) {
Criteria c = new Criteria ();
c.addEqualTo ("ID_PRJ", _iProjectFilter);
QueryByCriteria qc = new QueryByCriteria (Application.class, c);
return _broker.getIteratorByQuery (qc);
}
----------------------
-> but when i take this function, i get an 'java.lang.ClassCastException:
java.lang.String' exception!
(in the OJB-Version 0.8.375 this works)
----------------------
public static Iterator getAllPrj (PersistenceBroker _broker, String
_strProjectFilter) {
Criteria c = new Criteria ();
c.addEqualTo ("ID_PRJ", _strProjectFilter);
QueryByCriteria qc = new QueryByCriteria (Application.class, c);
return _broker.getIteratorByQuery (qc);
}
public static Iterator getAllPrj (PersistenceBroker _broker, Integer
_iProjectFilter) {
return getAllPrj (_broker, _iProjectFilter.toString());
}
----------------------
I use OJB 0.9.5 with an oracle-plattform.
thanks
Gerald
----------------------
-> REPOSITORY.XML
<!-- Tablle CTN_APPLICATION -->
<class-descriptor proxy="dynamic" class="carat.db.ctn.Application"
table="CTN_APPLICATION">
<field-descriptor id="1" name="ID_APPL" column="ID_APPL"
jdbc-type="INTEGER" primarykey="true"/>
<field-descriptor id="2" name="ID_DESCR" column="ID_DESCR"
jdbc-type="INTEGER"/>
<field-descriptor id="3" name="ID_PRJ" column="ID_PRJ"
jdbc-type="INTEGER"/>
</class-descriptor>
-----------------------
-> JUNIT
public void testClassicGetAllPrjAndIterate() {
try {
int j;
for (j=1; j<10; j++) {
Iterator it = Application.getAllPrj (m_broker, new Integer (j));
Assert.assertNotNull( "Classic: result is null!", it);
ApplicationIF myObj;
while (it.hasNext ()) {
myObj = (ApplicationIF)it.next();
assertNotNull("Classic: Object-Class Application is null!",
myObj);
System.out.println("Projekt -> " +
myObj.getDescription().getDescription() + " / " +
myObj.getProject().getDescription().getDescription());
}
}
} catch (Exception ex) {
ex.printStackTrace();
assertTrue( "ERROR in Application ->
testClassicGetAllPrjAndIterate", false);
}
}
------------------------
-> LOG-FILE
[junit] java.lang.ClassCastException: java.lang.String
[junit] at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement
.java:2354)
[junit] at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement
.java:2449)
[junit] at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Pl
atformDefaultImpl.java:176)
[junit] at
org.apache.ojb.broker.platforms.PlatformOracleImpl.setObjectForStatement(Pla
tformOracleImpl.java:108)
[junit] at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatementValue(Statem
entManager.java:204)
[junit] at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementMa
nager.java:244)
[junit] at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementMa
nager.java:406)
[junit] at
org.apache.ojb.broker.accesslayer.JdbcAccess.executeQuery(Unknown Source)
[junit] at
org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown Source)
[junit] at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getIteratorFromQuery(Un
known Source)
[junit] at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getIteratorByQuery(Unkn
own Source)
[junit] at carat.db.ctn.Application.getAllPrj(Application.java:109)
[junit] at carat.db.ctn.Application.getAllPrj(Application.java:112)
[junit] at
carat.db.ctn.Application$Test.testClassicGetAllPrjAndIterate(Application.jav
a:213)
[junit] at java.lang.reflect.Method.invoke(Native Method)
[junit] at junit.framework.TestCase.runTest(TestCase.java:166)
[junit] at junit.framework.TestCase.runBare(TestCase.java:140)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at
junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:131)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:173)
[junit] at junit.framework.TestSuite.run(TestSuite.java:168)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:173)
[junit] at junit.framework.TestSuite.run(TestSuite.java:168)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:173)
[junit] F
[junit] Time: 3,756
[junit] There was 1 failure:
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>