Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.1
Mapping documents:
The mapping doc maps to a view which joins two base tables throught a foreign key.
Code between sessionFactory.openSession() and session.close():
Transaction tx = seesion.beginTransaction();
Criteria crit = session.createCriteria(SomeView.class)
.add(Expression.eq("id", new Long(pid)))
.add(Expression.eq("status", new String("R")));
List products = crit.list();
for (int i=0; i<products.size(); i++) {
SomeView p = (SomeView) products.get (i);
p.setType("LHP");
session.saveOrUpdate(p);
}
tx.commit();
Full stack trace of any exception that occurs:
net.sf.hibernate.JDBCException: could not update: [com.lowermybills.spreport.engine.loans.HomeLoansApplicationView#6984028]
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:706)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:641)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2382)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2336)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.lowermybills.spreport.engine.loans.HomeLoanPersistenceManager.main(HomeLoanPersistenceManager.java:159)
Caused by: java.sql.SQLException: ORA-01779: cannot modify a column which maps to a non key-preserved table
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1602)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1527)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2045)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:395)
at com.mchange.v2.sql.filter.FilterPreparedStatement.executeUpdate(FilterPreparedStatement.java:71)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:688)
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
It seems like it is updating every field in that view where I only want to update one filed (Type), which is updatable in Oracle (I can tell this by querying the user_updatable_columns table). The filed 'Type' is in the key-preserved table. But, somehow Hibernate is complaining the field is mapped to a non key-preserved table. Is this a bug of Hibernate?