db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony S. Kraievoy" <archv...@ukr.net>
Subject Issue with HSQLDB manager
Date Sun, 08 Dec 2002 21:36:46 GMT
Hi all
huh...  i think it may be an interesting issue for developers...
I use OJB 0.9.7
What i did:
OJB was running against hsqldb, i've just (in previous build) defined new class-descriptor
for a table,
wrote new class itself. And wrote simple code snippet that gets extent for new class and uses
it to render
it in html.
Table was empty -- all was ok. I viewed pretty and empty table.
Then, i started up hsqldb manager and inserted new record to this table. :)))).
Just because i was lazy and wanted to view presentation without writing some forms for creation
of new records.
Then i concecutively tried to view html presentation of this record.

What happened every time i tried to view this table:
1. My code tried to get extent.
2. OJB tried to WRITE this record once more time to DB! (this was totally unexpected)
<thise steps below are specific to my app>
3. and HSQLDB didn't allow it because of unique constraint on one field (it will be duplicated
otherwise) (this is MY 
trouble).
4. OJB rolled back transaction in which i tried to get extent.
5. My code caught exception, but presentation logic crashed at next step (this is surely MY
trouble)
because code got null instead of empty collection.

OJB considers that newly created out of app record must be WRITTEN to db once more...
Or it was assumed that db will be modified only by OJB?

IMO OJB's behaviour was more unusual than mine was. :)

here is some SQL about it...

1:INSERT INTO DIM (DIM_ID,NAME,SHORTCUT,ISINT) VALUES (0,'bla-bla','bla',true) // that i did
through manager
0:SELECT A0.ISINT,A0.DIM_ID,A0.NAME,A0.SHORTCUT FROM DIM A0 // getting extent
2:SET AUTOCOMMIT FALSE
2:SELECT MAX_KEY,TABLENAME,GRAB_SIZE,FIELDNAME FROM OJB_HL_SEQ WHERE TABLENAME = 'DIM'  AND
FIELDNAME = 'ID'
2:COMMIT
2:SELECT MAX(DIM_ID) FROM DIM
3:SET AUTOCOMMIT FALSE
3:SELECT MAX_KEY,TABLENAME,GRAB_SIZE,FIELDNAME FROM OJB_HL_SEQ WHERE TABLENAME = 'DIM'  AND
FIELDNAME = 'ID'
3:INSERT INTO OJB_HL_SEQ (TABLENAME,FIELDNAME,MAX_KEY,GRAB_SIZE) VALUES ( 'DIM', 'ID', 10,
10 )
3:COMMIT
0:SELECT ISINT,DIM_ID,NAME,SHORTCUT FROM DIM WHERE DIM_ID = 1
0:INSERT INTO DIM (DIM_ID,SHORTCUT,NAME,ISINT) VALUES ( 1, 'bla', 'bla-bla', TRUE ) // ?!?
0:ROLLBACK

after restarting the app the problem remains. But OJB tries to insert record with id 11 instead
of 1.

5:SELECT MAX_KEY,TABLENAME,GRAB_SIZE,FIELDNAME FROM OJB_HL_SEQ WHERE TABLENAME = 'DIM'  AND
FIELDNAME = 'ID'
5:COMMIT
5:SELECT MAX_KEY,TABLENAME,GRAB_SIZE,FIELDNAME FROM OJB_HL_SEQ WHERE TABLENAME = 'DIM'  AND
FIELDNAME = 'ID'
5:UPDATE OJB_HL_SEQ SET MAX_KEY=20, GRAB_SIZE=10 WHERE TABLENAME = 'DIM'  AND FIELDNAME =
'ID'
5:COMMIT
4:SELECT ISINT,DIM_ID,NAME,SHORTCUT FROM DIM WHERE DIM_ID = 11
4:INSERT INTO DIM (DIM_ID,SHORTCUT,NAME,ISINT) VALUES ( 11, 'bla', 'bla-bla', TRUE )
4:ROLLBACK

tried to clean (when app was down) OJB_HL_SEQ. Returned to first snippet of SQL, as was expected.

I shot down app and DB. Then changed id with this new record to from 0 to 1. Restarted. All
became ok.

Maybe the problem was related to value of primary key (id was zero).

My ddl for this table:

CREATE TABLE DIM(DIM_ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,
  SHORTCUT VARCHAR NOT NULL,ISINT BIT NOT NULL,CONSTRAINT UNIQUE_NAME UNIQUE(NAME))

XML descriptor for new class:

<class-descriptor class="com.archvile.ooo.business.model.ProductDimension" table="DIM"
isolation-level="read-committed">
  <field-descriptor id="1" name="ID"       column="DIM_ID"   jdbc-type="INTEGER" primarykey="true"
autoincrement="true"/>
  <field-descriptor id="2" name="shortcut" column="SHORTCUT" jdbc-type="VARCHAR" nullable="false"/>
  <field-descriptor id="3" name="name"     column="NAME"     jdbc-type="VARCHAR" nullable="false"
indexed="true"/>
  <field-descriptor id="4" name="discrete" column="ISINT"    jdbc-type="BIT"     nullable="false"/>
</class-descriptor>


Mime
View raw message