views:

452

answers:

1

I have a simple method that just does two lines and tries to return all objects in an oracle database table:

DetachedCriteria criteria = DetachedCriteria.forClass(Object.class);
return (Collection)getHibernateTemplate().findByCriteria(criteria);

However, I got an "ORA-01031: insufficient privileges" error. When I checked the logs for the show_sql, I found this:

Hibernate: select this_.NAME as NAME8_0_, from PL_VW this_ where ID=?
Hibernate: update PL_VW set NAME=? where ID=?
Hibernate: update PL_VW set NAME=? where ID=?
Hibernate: update PL_VW set NAME=? where ID=?
Hibernate: update PL_VW set NAME=? where ID=?
Hibernate: update PL_VW set NAME=? where ID=?
...

Why does findByCriteria select an ID and do multiple updates? Must update access be given for all tables that are hooked to hibernate? I do not wish the tables be updated!

Or is something wrong with the code?

Thanks in advance.

A: 

Yes it was supposed to return all objects.

I found out the most un-obvious problem:

In the getName method, I did some substring functions and returned a modified string.

I guess hibernate immediately tried to update the database with what was returned in getName. (What?! Why?!)

Was this mentioned anywhere in the Hibernate docs or was it supposed to be common sense??? What a noob I am.

Thanks guys anyway for all your help.