Hi..
I have a one-to-many relation between table WB_ARTIKELKATEGORIE and table WB_ARTIKELKATEGORIEANZEIGE.
I load one entitity of A with this from hibernate generated sql;
Code:
select
wbartikelk0_.KATEGORIE_ID as KATEGORIE1_2_,
wbartikelk0_.MARKEN_ID as MARKEN2_2_,
wbartikelk0_.VERTRAGSART_ID as VERTRAGS3_2_,
wbartikelk0_.ANZEIGEN as ANZEIGEN2_,
wbartikelk0_.ZUORDNUNGS_ID as ZUORDNUNGS5_2_,
wbartikelk0_.LAST_MODIFIED_BY as LAST6_2_,
wbartikelk0_.SORTIERUNG as SORTIERUNG2_
from
ETNWEB.WB_ARTIKELKATEGORIE wbartikelk0_
where
trim(wbartikelk0_.MARKEN_ID)=?
and wbartikelk0_.VERTRAGSART_ID=?
and wbartikelk0_.KATEGORIE_ID=?
this is working fine. NOW i want to get the entities of table WB_ARTIKELKATEGORIEANZEIGE which are assoiciated with the loaded entity.
Code:
select
wbartikelk0_.MARKEN_ID as MARKEN3_1_,
wbartikelk0_.KATEGORIE_ID as KATEGORIE2_1_,
wbartikelk0_.VERTRAGSART_ID as VERTRAGS4_1_,
wbartikelk0_.ART_ID as ART1_1_,
wbartikelk0_.LAND as LAND1_,
wbartikelk0_.ART_ID as ART1_3_0_,
wbartikelk0_.KATEGORIE_ID as KATEGORIE2_3_0_,
wbartikelk0_.MARKEN_ID as MARKEN3_3_0_,
wbartikelk0_.VERTRAGSART_ID as VERTRAGS4_3_0_,
wbartikelk0_.LAND as LAND3_0_,
wbartikelk0_.LAST_MODIFIED_BY as LAST6_3_0_,
wbartikelk0_.SORTIERUNG as SORTIERUNG3_0_
from
ETNWEB.WB_ARTIKELKATEGORIEANZEIGE wbartikelk0_
where
wbartikelk0_.MARKEN_ID=?
and wbartikelk0_.KATEGORIE_ID=?
and wbartikelk0_.VERTRAGSART_ID=?
This statment results in a an exception which is caused by incompatible data types.
the problem lies in the order of the binding parameters:
Code:
14:38:37,704 DEBUG IntegerType:79 - binding '30585' to parameter: 1
14:38:37,719 DEBUG StringType:79 - binding 'V ' to parameter: 2
14:38:37,719 DEBUG IntegerType:79 - binding '1' to parameter: 3
The binding with the value 'V ' should be binded to the first where condition ( wbartikelk0_.MARKEN_ID=? ).
After some trial and error i found the problem in this piece of code.
Code:
@JoinColumns( {
@JoinColumn(name = "MARKEN_ID", unique = false, nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "KATEGORIE_ID", unique = false, nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "VERTRAGSART_ID", unique = false, nullable = false, insertable = false, updatable = false) })
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
public WbArtikelkategorie getWbArtikelkategorie() {
return this.wbArtikelkategorie;
}
After swapping the first with the second join column the application is working as intended.
But where is the binding parameter order defined or is it possible to define the order of the parameter bindings?
Is this a shortcoming of hibernate or some error on our side?!
thx for your help
stefon
Hibernate version: 3.1 rc3
Full stack trace of any exception that occurs:Code:
Exception in thread "main" 14:38:37,735 WARN JDBCExceptionReporter:71 - SQL Error: 1722, SQLState: 42000
14:38:37,735 ERROR JDBCExceptionReporter:72 - ORA-01722: Ungültige Zahl
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [bsp08.model.WbArtikelkategorie.wbArtikelkategorieanzeiges#component[kategorieId,markenId,vertragsartId]{vertragsartId=1, kategorieId=30585, markenId=V }]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1923)
at org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:52)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1493)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
at org.hibernate.collection.PersistentSet.size(PersistentSet.java:114)
at bsp08.Bsp08.main(Bsp08.java:94)
Caused by: java.sql.SQLException: ORA-01722: Ungültige Zahl
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:831)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2496)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2840)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:536)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1676)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
... 9 more
Name and version of the database you are using:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production