with a simple FieldConversion, now all my Integer-fields also work on Oracle.
that's for help ;-)
with best wishes Kristian
Mahler Thomas wrote:
Hi again,
-----Original Message----- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 11:54 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle
Hi Thomas,
just to understand, if
repository.xml
is wrongly configured it shouldn't work with mysql, hsqldb as well not oracle.
I don't agree. Oracles datatype NUMBER is something completely different than the INTEGER type on MySql or Hsqldb! Oracle NUMBER expects a BigInt on the java side. If you want something different you definitely need a FielConversion.
cheers, Thomas
basically the same file (the platform attribute changes respectivly) works fine for mysql, hsqldb, but
not for oracle !!! all java classes are the same in each case, and the underlying java class has an int !!
so I would appreciate some further hints !!
with best wishes Kristian
Mahler Thomas wrote:
Hi Kristian,configuration problem.
For me this does not look like a OJB bug, but as a
If you have a java attribute of type String but have definedit as INTEGER
in the repository.xml you've got a problem!Oracle Number
If you want to have a String attribute converted into an
where theycolumn you should use a FieldConversion but not change the PlatformOracleImpl.
cheers, thomas
-----Original Message----- From: kristian meier [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 9:46 AM To: OJB Users List Subject: Re: Possible OJB Bug with Oracle
Hello,
when I yesterday switch to oracle I came across the same exception and I investigated a bit, and
found an unexpected situation in the PlatformOracleImpl.java
in the setObjectForStatement( .... ) method the sqlType was Type.INTEGER and the value was a String class
both arguments were passed to the PlatformDefaultImpl.java
sqlType);were passed into the PreparedStatement.
the String class seemed to be already wrong at this place, but a simple hack does work fine for me:
*** PlatformOracleImpl.java Sun May 4 14:08:14 2003
--- src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Jun 5 09:17:58 2003
***************
*** 126,131 ****
--- 126,138 ----
ps.setLong(index, ((Integer) value).intValue());
}
+ else if (sqlType == Types.INTEGER && value instanceof String)
+ {
+ // workaround:
+ ps.setInt(index, Integer.parseInt( (String) value ) );
+ }
else
{
+ this.logger.debug( "using type " + sqlType + " for class " + value.getClass().getName()
+ + "(" + value + ")" );
super.setObjectForStatement(ps, index, value,
<[EMAIL PROTECTED]>}
maybe this also helps to find the real bug !!!
with best wishes Kristian
Brown, Melonie S. - Contractor wrote:
Has anybody else ran into this? This is a big problem forus, and I'm
catching a lot of flack since I recommended we use OJB.though the code
It appears that OJB is generating a getCollection query even
specifies a single object.would be greatly
I'm not sure where to begin debugging, so any assistance
appreciated.ClassCastException with Oracle
-------- Original Message --------
Subject: [RC3] Works with MySql, Fails with
Date: Thu, 29 May 2003 11:41:00 -0400
From: Brown, Melonie S. - Contractor
----------and dies againstReply-To: OJB Users List <[EMAIL PROTECTED]> Newsgroups: gmane.comp.jakarta.ojb.user
I have code that works perfectly fine in MySQL but crashes
an Oracle database. I'm getting a java.lang.ClassCastException atthe spy.log file.
GetCollectionByQuery which doesn't make sense since I'm calling
broker.getObjectbyQuery. Also, no SQL statements show in
Suggestions would be greatly appreciated.DataStoreException
This is the code:
public static RcioDB retrieveRcio(RcioDB sRcio) throws
QueryFactory.newQuery(RcioDB.class,{ PersistenceBroker broker = GetAccess.getPersistenceBroker();
try { broker.beginTransaction();
Criteria crit = new Criteria();
crit.addEqualTo( Constants.RCIO_ID, String.valueOf(sRcio.getRcio_ID()));
System.out.println("criteria set");
QueryByCriteria query =
broker.getObjectByQuery(query);crit); System.out.println("query created");
Object theRcioToBeFetched =
INFO: Rollback wasSystem.out.println("after fetch"); System.out.println(theRcioToBeFetched.getClass()); return (RcioDB)theRcioToBeFetched; } catch (Throwable t) { t.printStackTrace(); throw new DataStoreException(t.toString()); } finally { broker.close(); }
This is the output from the log:
criteria set
query created
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl]
called, do rollback on current connectionnByQuery(Persis
[EMAIL PROTECTED]
org.apache.ojb.broker.PersistenceBrokerException:
java.lang.ClassCastException
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio
tenceBrokerImpl.java:1467)nByQuery(Persis
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio
tenceBrokerImpl.java:1496)nByQuery(Persis
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio
tenceBrokerImpl.java:1485)uery(Persistenc
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQ
eBrokerImpl.java:1747)ectByQuery(Dele
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObj
gatingPersistenceBroker.java:271)(RcioCRUD.java:
at
mil.army.forscom.tsamsweb.rcio.database.RcioCRUD.retrieveRcio
131)rtRcios(InsertR
at
mil.army.forscom.tsamsweb.rcio.tests.InsertRciosTest.testInse
ciosTest.java:59)sorImpl.java:39
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
)hodAccessorImpl
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
.java:25)ts(RemoteTestRu
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTes
nner.java:392)moteTestRunner.
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(Re
java:276)emoteTestRunner
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(R
.java:167)eparedStatement
Caused by: java.lang.ClassCastException
at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePr
.java:2804)eparedStatement
at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePr
.java:2905)Statement.java:
at
com.p6spy.engine.spy.P6PreparedStatement.setObject(P6Prepared
282)ForStatement(Pl
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObject
atformDefaultImpl.java:230)orStatement(Pla
at
org.apache.ojb.broker.platforms.PlatformOracleImpl.setObjectF
tformOracleImpl.java:130)entValue(Statem
at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatem
entManager.java:262)ent(StatementMa
at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatem
nager.java:296)ionCriteria(Sta
at
org.apache.ojb.broker.accesslayer.StatementManager.bindSelect
tementManager.java:474)ent(StatementMa
at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatem
nager.java:438)ent(StatementMa
at
org.apache.ojb.broker.accesslayer.StatementManager.bindStatem
nager.java:410)(JdbcAccessImpl
at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery
.java:258)r.java:199)
at
org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterato
atator(RsIterator
org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIter
FactoryImpl.java:95)rFromQuery(Pers
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIterato
istenceBrokerImpl.java:2311)romQuery(Persis
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorF
tenceBrokerImpl.java:1657)nByQuery(Persis
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio
tenceBrokerImpl.java:1305)nByQuery(Persis
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectio
tenceBrokerImpl.java:1460)rNextValImpl">
My repository.xml:
<jdbc-connection-descriptor
platform="Oracle"
jdbc-level="2.0"
driver="com.p6spy.engine.spy.P6SpyDriver"
protocol="jdbc"
subprotocol="Oracle"
dbalias="thin:@machinestuff"
username="user"
password="password"
jcd-alias="default"
default-connection="true"
batch-mode="false"
useAutoCommit="1"
ignoreAutoCommitExceptions="false" >
<sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManage
</sequence-manager>
</jdbc-connection-descriptor>
The repository_user file: <class-descriptor class="foo.RcioDB" table="rcio" > <field-descriptor name="Rcio_ID" column="RCIO_ID" jdbc-type="INTEGER" primarykey="TRUE" autoincrement="false" indexed="true" /> <field-descriptor name="Rcio_Short_Name" column="RCIO_SHORT_NAME" jdbc-type="VARCHAR" primarykey="false" autoincrement="false" /> <field-descriptor name="Rcio_Desc" column="RCIO_DESC" jdbc-type="VARCHAR" primarykey="false" autoincrement="false" /> </class-descriptor>
-----------------------------------------------------------
---------------------------------------------------------------------To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
