一个表A中有3个字段作为复合主键
在hibernate的xml中映射为复合主键类:
      <composite-id name="id" class="pkg.AID">
            <key-property name="a" type="string">
                <column name="a" length="20" />
            </key-property>
            <key-property name="b" type="string">
                <column name="b" length="2" />
            </key-property>
            <key-property name="c" type="string">
                <column name="c" length="20" />
            </key-property>
        </composite-id>
实体类:
class A{
 private AID id;
 private String no;
 ...略
}
class AID{
 private String a;
 private String b;
 private String c;
 ...略
}
在使用的时候,用hql查询时没有问题
aaaDao.findByHql("from A where id.a='xxx'");
但是在使用更新就会出问题
class ttt{
 private static BaseHibernateDAO aDao = new BaseHibernateDAO("pkg.A");
 public static void main(String[] args){
   aDao.UpdateByHQL("update A set no='1' where id.a='b'");
 }
}
这样就不可以了。请假各位大侠。
org.hibernate.exception.GenericJDBCException: 
    could not execute update query
Caused by: 
    java.sql.SQLException: The column prefix 'movecontpl0_' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.由于特殊原因,现在不想改动xml为
<composite-id>
  <key-propertyname="a"column="a"type="string"/>
  <key-propertyname="b"column="b"type="string"/>
  <key-propertyname="c"column="c"type="string"/>
</composite-id>
因为这个改掉的话会使很多地方都要改动,所以问问大侠们有什么好办法没有,现在这种情况就只是可以查询
不可以更新和删除
谢谢。