db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schwarzkopf, Alexander" <Alexander.Schwarzk...@stratos-gruppe.de>
Subject ojb with oracle have some bugs
Date Tue, 15 Jun 2004 07:08:00 GMT
hallo zusammen.
ich habe grosse interesse an OJB und versuchte einige einfache Tests fuer datenbanken
mysql, mssql, sybase, informix und oracle durchzufuehren. Es schein in Grundfunktionalitaeten
von PersistanceBroker-Implementation gibt (es ist auch verstaendlich) noch Fehler.
Ich haenge Ausschnitte aus Programm. das Problem ist folgendes.
wenn ich in crit.addEqualTo("id", Integer.toString( key )  )
die Klassenvariable benutze, schlaegt die methode getObjectByQuery( query ) fehl.
Wenn ich aber in crit.addEqualTo("nummer", Integer.toString( key )  ) den Spaltennamen benutze
funktioniert es. Benutzen von Spaltennamen  hier ist aber nicht der Sinn der Sache und uebrigens
sollte ich dann immer Spaltennamen und Klassenvariablen gleich nennen.
--------------------------------------------------------------------------------
I have a big interest for OJB and try to make some simply tests with db mysql, mssql, sybase,
informix and oracle.
it seems that PersistanceBroker implementation has some basic error. I attached one of unfortunal
test with part of class, retrieve-method and repository_user-file to explain, what is wrong
for Oracle-DB(9i).
If in crit.addEqualTo("id", Integer.toString( key )  )  the class member id was used, it caused
an errror at
oracle.jdbc.driver.OraclePreparedStatement.setObject
but if I used in crit.addEqualTo("nummer", Integer.toString( key )  )  the column name, it
works. 
I mean it isn't sense of order  that class member name is equal to column name in the table
of database

with greeting from D
alex schwarzkopf

Alexander.Schwarzkopf@stratos-gruppe.de

-------------------------------------------------------------
/*        MyClass declaration       */

public class MyClass
  {
  private int id;
  private String name;
  public int getId(){ return id; };
  public String  getName(){ return name; };
  public void setId( int val ){ id = val; };
  public void setName( String val ){ name = val; };
  }

<!-- repository_user.xml  -->

<class-descriptor
  class="bo.MyClass"
  table="KOSTELLE"
> 
  <field-descriptor  
     name="id"
     column="NUMMER"
     jdbc-type="INTEGER"
     primarykey="true" 
  />
  <field-descriptor  
     name="name"
     column="KURZTEXT"
     jdbc-type="VARCHAR"
  />
</class-descriptor>
<!-- -------------------------------- -->
/*        function im main Class       */

public MyClass retrieveData(int key )
  {
  Criteria crit = new Criteria();
  /*crit.addEqualTo("nummer", Integer.toString( key )  );*/
  crit.addEqualTo("id", Integer.toString( key )  );
  QueryByCriteria query = new QueryByCriteria( MyClass.class, crit );
  System.out.println("retrieve or not retrieve?" );
  return(MyClass)broker.getObjectByQuery( query );
  }

/*        error       */
retrieve or not retrieve?
java.lang.ClassCastException
	at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2018)
	at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2099)
	at com.p6spy.engine.spy.P6PreparedStatement.setObject(P6PreparedStatement.java:294)
	at org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(PlatformDefaultImpl.java:227)
	at org.apache.ojb.broker.platforms.PlatformOracleImpl.setObjectForStatement(PlatformOracleImpl.java:137)
	at org.apache.ojb.broker.accesslayer.StatementManager.bindStatementValue(StatementManager.java:216)
	at org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementManager.java:248)
	at org.apache.ojb.broker.accesslayer.StatementManager.bindSelectionCriteria(StatementManager.java:424)
	at org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementManager.java:388)
	at org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementManager.java:361)
	at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl.java:278)
	at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(RsQueryObject.java:74)
	at org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:183)
	at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIteratorFactoryImpl.java:58)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(PersistenceBrokerImpl.java:1780)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(PersistenceBrokerImpl.java:1321)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1432)
	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
	at TestOra1.retrieveData(TestOra1.java:27)
	at TestOra1.main(TestOra1.java:39)
Exception in thread "main" 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message