Hello,
I am using Oracle 10g and I have strange error that I cannot resolve.
Below are tables with most data columns snipped (otherwise they would be to long)
When I do
Code:
String query = "from BBB si WHERE si.sifra=?";
Query q = s.createQuery(query);
q.setParameter(0, sifra10crk);
Object o = q.uniqueResult();
SifrantIzpostava si = (SifrantIzpostava) o;
I get null. But if I remove the line below from AAA definition, it works:
,foreign key (IZPOSTAVA_ID) references BBB(id) on delete cascade
Generated SQL returns one row, which is correct. Hibernate log says that 0 rows were returned.
Any ideas?
PS. I changed some names for improved readability, and the code works if foreign key constraint in database is removed, so any typo in there is not the cause.
Thanks.
------ DATABASE ---------
Code:
CREATE TABLE AAA(
ID NUMBER(4) NOT NULL
,IZPOSTAVA_ID NUMBER(4) NOT NULL
,constraint PKAAA primary key (id)
,foreign key (IZPOSTAVA_ID) references BBB(id) on delete cascade
)
/
CREATE TABLE BBB(
ID NUMBER(4) NOT NULL
,SIFRA VARCHAR2(10) NOT NULL
,constraint PKSifrantIzpostava primary key (ID)
,constraint BKSifrantIzpostava unique (SIFRA)
)
/
-------- LOG ----------
:18:22,042 DEBUG BatcherImpl:249 - preparing statement
4536 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
12:18:22,293 DEBUG Loader:277 - processing result set
4787 [main] DEBUG net.sf.hibernate.loader.Loader - processing result set
12:18:22,293 DEBUG Loader:294 - done processing result set (0 rows)
4787 [main] DEBUG net.sf.hibernate.loader.Loader - done processing result set (0 rows)
12:18:22,293 DEBUG BatcherImpl:207 - done closing: 0 open PreparedStatements, 0 open ResultSets
4787 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
12:18:22,293 DEBUG BatcherImpl:269 - closing statement