Hibernate LEFT JOIN

时间:2017-05-09 08:02:20

标签: java mysql hibernate

this mysql query 的Hibernate查询给出了以下错误

FROM RecordItems t1
LEFT JOIN PropertyValues t2 where t2.property = 'age'ORDER BY CASE WHEN t2.value IS NULL THEN 1 ELSE 0 END, t2.value
  

例外:加入的预期路径!

 FROM RecordItems t1
    LEFT JOIN PropertyValues t2 ON t1.id = t2.REC where t2.property = 'age'ORDER BY CASE WHEN t2.value IS NULL THEN 1 ELSE 0 END, t2.value
  

异常:意外令牌:在第1行附近开启

下面提供了Hibernate映射和实体详细信息:

public class RecordItems implements java.io.Serializable {
     private Integer id;
     private String col1;
     private String col2;
     private String col3;
}
public class PropertyValues implements java.io.Serializable {
     private Integer id;
     private RecordItems REC;
     private String property;
     private String value;

}

<?xml version="1.0"?>
<schema package="com.test.p.schema" name="Core Package">
<Class name="RecordItems"table="record_items">
        <id name="id" type="integer"column="ID" ><generator class="native" /></id>
        <property name="col1" type="String"  column="col1" />
        <property name="col2" type="String"  column="col2" />
        <property name="col3" type="String"  column="col3" />

    </Class>
<Class name="PropertyValues "table="property_values">
        <id name="id" type="integer"column="ID" ><generator class="native" /></id>
        <foreign cardinality="many"name="REC" class="RecordItems" column="REC" />
        <property name="property" type="String"  column="property" />
        <property name="value" type="String"  column="value" />

    </Class>
</schema>

0 个答案:

没有答案