PDA

View Full Version : ROWID and Hibernate (OT :(



MmarcoM
Jul 28th, 2009, 11:19 AM
Hello all,
i do apolgize posting here but i found no answer in hibernate forums and i thought someone here could have come across my problem

I am trying to map a table which has one column of type ROWID

I couldn ot find any hibernate type associated, so i defined it as a Varchar (from the database , it looks like a varchar at least)..

I am able to retrieve data usign find(), and i am also able to use the ROWID to find the row int eh corresponding table

However, when i try to delete my object hibernate fails..
First off, it does not delete the object (row in teh db i sstill there)

secondly, if i call a finder after the delete method (to verify the row has been deleted) i got an ORA-01722 invalid number

i THINK hibernate thinks that the ROWID is a long, while in the db it appears like a varchar

well, was wondering if anyone came across to similar problems....

otherwise, sorry for spamming..

regards
marco

karldmoore
Jul 28th, 2009, 11:43 AM
Is it possible to see the mapping, code and db schema?

MmarcoM
Jul 29th, 2009, 03:13 AM
Hello Karldmoore,
thanks for replying..
i m using JPA



table schema is this

TABLE_NAME VARCHAR
ROW_ID ROWID
TYPE VARCHAR
TIME TIMESTAMP




Mapping docs (i m using JPA)
@Column(name = "TABLE_NAME", insertable = false, updatable = false)
private final String tableName;
@Column(name = "ROW_ID", insertable = false, updatable = false)
private final String rowId;
@Enumerated
@Column(name = "TYPE", insertable = false, updatable = false)
private final EventType eventType;
@Column(name = "TIME", insertable = false, updatable = false)
private final Date eventTime;


As i said, if i use a String for ROW_ID it works fine while finding objects, but it fails while deleting with an ORA-01722 error, probably because Hibernate thinks that ROWID is a long.

any help?

regards
marco

MmarcoM
Jul 29th, 2009, 06:55 AM
sorted, apologies..... i jsut didn have time for my tests

problem was actually the Enum type, i didnt map it as EnumType.STRING and therefore it was converting it to a number

I spotted it initially by using dbunit / hsql , i had to enter a number. then when i ran it for real (against oracle) ig ot again the ORA-01722 and from there i got to teh source of thep roblem

sorry for spamming

regards
marco