Hi,
Sory about not using the code tag. I managed to solve the problem with the following...
Code:
public void setAssociatedDocumentsAsPosted(MainDocument document,
String ownerLogin) {
HibernateUtils.currentSession()
.createQuery(new StringBuffer(
"update pl.addcom.df.AssociatedDocument ad ")
.append("set ad.everPosted = :everPosted ")
.append("where ad.owner = ( from pl.addcom.df.Employee ")
.append("where e.login = :ownerLogin) and ")
.append("ad.mainDocument = :mainDocument ")
.toString())
.setBoolean("everPosted", Boolean.TRUE)
.setString("ownerLogin", ownerLogin)
.setEntity("mainDocument", document)
.executeUpdate();
}
The SQL generated by the original code was not ok since there's no login property in the document (I mean the comma was not the only issue there). However... the AssociatedDocument -> Employee (owner) association is one point association and is of course navigable from the AssociatedDocument to Employee (It actually is defined in the Document class which is the superclass for AssociatedDocument) so I think the original code (expecially the following HQL "where ad.owner.login = :owner and") should produce correct SQL and work anyway.
The hibernate.cfg.xml is as follows (if it ever helps you :) )
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="hibernate.connection.driver_class">
com.ibm.db2.jcc.DB2Driver
</property>
<property name="hibernate.connection.url">
jdbc:db2:TEST
</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">
org.hibernate.dialect.DB2Dialect
</property>
<property name="hibernate.connection.pool_size">4</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.provider_configuration_file_resource_path">/ehcache.xml</property>
<property name="hibernate.cache.use_query_cache">true</property>
<!-- mapping files -->
<mapping resource="pl/addcom/df/Attachment.hbm.xml"/>
<mapping resource="pl/addcom/df/AttachmentHistory.hbm.xml"/>
<mapping resource="pl/addcom/df/Customer.hbm.xml"/>
<mapping resource="pl/addcom/df/CustomerHistory.hbm.xml"/>
<mapping resource="pl/addcom/df/DFileServer.hbm.xml"/>
<mapping resource="pl/addcom/df/DDocumentStatus.hbm.xml"/>
<mapping resource="pl/addcom/df/DDocumentType.hbm.xml"/>
<mapping resource="pl/addcom/df/DEmployeeStatus.hbm.xml"/>
<mapping resource="pl/addcom/df/DLanguage.hbm.xml"/>
<mapping resource="pl/addcom/df/DPhone.hbm.xml"/>
<mapping resource="pl/addcom/df/DPosition.hbm.xml"/>
<mapping resource="pl/addcom/df/DRegistry.hbm.xml"/>
<mapping resource="pl/addcom/df/DRoom.hbm.xml"/>
<mapping resource="pl/addcom/df/DUnifiedDocRegistry.hbm.xml"/>
<mapping resource="pl/addcom/df/DUnit.hbm.xml"/>
<mapping resource="pl/addcom/df/DocumentTrackRecord.hbm.xml"/>
<mapping resource="pl/addcom/df/DocumentStatusChangeRecord.hbm.xml"/>
<mapping resource="pl/addcom/df/Document.hbm.xml"/>
<mapping resource="pl/addcom/df/DocumentHistory.hbm.xml"/>
<mapping resource="pl/addcom/df/Employee.hbm.xml"/>
<mapping resource="pl/addcom/df/Absence.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeToLanguage.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeToDUnit.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeEntryToDPhone.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeEntryToDRoom.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeEntry.hbm.xml"/>
<mapping resource="pl/addcom/df/CustomerLoginRecord.hbm.xml"/>
<mapping resource="pl/addcom/df/EmployeeLoginRecord.hbm.xml"/>
<mapping resource="pl/addcom/df/ExternalContent.hbm.xml"/>
<mapping resource="pl/addcom/df/Message.hbm.xml"/>
<mapping resource="pl/addcom/df/Permissions.hbm.xml"/>
<mapping resource="pl/addcom/df/DStructureNode.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Regards
Chris