简体   繁体   中英

JPA where clause condition

I'm using hibernate 3 within this mapping in hbm.xml file:

<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) .

You can use the @where annotation, see this link for details:

Hibernate @Where clause

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 {
   ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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