-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Can I update an updatable field in a joined view
PostPosted: Mon Apr 04, 2005 6:30 pm 
Newbie

Joined: Tue Oct 12, 2004 5:56 pm
Posts: 3
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.