简体   繁体   English

JPA where子句条件

[英]JPA where clause condition

I'm using hibernate 3 within this mapping in hbm.xml file: 我在hbm.xml文件的此映射中使用了休眠3:

<class table="mtl_material_transactions" 
        name="com.kaka.oracle.model.inventory.transactions.MaterialTransaction" 
        where="transaction_type_id in (35,44,90)" 
        schema="apps">

The key point is where , how can I do the same with JPA 2.0 (hibernate 4.1.9 final as provider) . 关键是where ,我该如何使用JPA 2.0 (作为提供商的Hibernate 4.1.9 final)做同样的事情。

You can use the @where annotation, see this link for details: 您可以使用@where批注,有关详细信息,请参见此链接:

Hibernate @Where clause 休眠@Where子句

For example your entity looks like this: 例如,您的实体如下所示:

@Entity
@Table(name = "mtl_material_transactions", schema="apps")
@Where(clause="transaction_type_id in (35,44,90)")
public class MaterialTransaction {
   ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM