XML 中的 Hibernate 数据过滤器多对一映射文件

发布于 2025-01-09 14:12:24 字数 1607 浏览 0 评论 0原文

我想知道如何在多对一映射中添加数据过滤器。

放置示例代码:

<hibernate-mapping>
   <class name = "Employee" table = "EMPLOYEE">
      
      <meta attribute = "class-description">
         This class contains the employee detail. 
      </meta>
      
      <id name = "id" type = "int" column = "id">
         <generator class="native"/>
      </id>
      
      <property name = "firstName" column = "first_name" type = "string"/>
      <property name = "lastName" column = "last_name" type = "string"/>
      <property name = "salary" column = "salary" type = "int"/>
      <many-to-one name = "address" column = "address" 
         class="Address" not-null="true"/>
         
   </class>

   <class name = "Address" table="ADDRESS">
      
      <meta attribute = "class-description">
         This class contains the address detail. 
      </meta>
      
      <id name = "id" type = "int" column = "id">
         <generator class="native"/>
      </id>
      
      <property name = "street" column = "street_name" type = "string"/>
      <property name = "city" column = "city_name" type = "string"/>
      <property name = "state" column = "state_name" type = "string"/>
      <property name = "zipcode" column = "zipcode" type = "string"/>
      
   </class>

</hibernate-mapping>

基本上,我想添加一个过滤器来获取居住在城市(例如:Chennai)的员工,

  <filter name="cityFilter" condition="city=:cityFilterParam)"/>

有人可以告诉我它是如何实现的吗?

I am wondering how to add a data filter in many to one mapping.

Putting a sample code:

<hibernate-mapping>
   <class name = "Employee" table = "EMPLOYEE">
      
      <meta attribute = "class-description">
         This class contains the employee detail. 
      </meta>
      
      <id name = "id" type = "int" column = "id">
         <generator class="native"/>
      </id>
      
      <property name = "firstName" column = "first_name" type = "string"/>
      <property name = "lastName" column = "last_name" type = "string"/>
      <property name = "salary" column = "salary" type = "int"/>
      <many-to-one name = "address" column = "address" 
         class="Address" not-null="true"/>
         
   </class>

   <class name = "Address" table="ADDRESS">
      
      <meta attribute = "class-description">
         This class contains the address detail. 
      </meta>
      
      <id name = "id" type = "int" column = "id">
         <generator class="native"/>
      </id>
      
      <property name = "street" column = "street_name" type = "string"/>
      <property name = "city" column = "city_name" type = "string"/>
      <property name = "state" column = "state_name" type = "string"/>
      <property name = "zipcode" column = "zipcode" type = "string"/>
      
   </class>

</hibernate-mapping>

basically, I want to add a filter that fetches the employee who lives in a city(ex: Chennai)

  <filter name="cityFilter" condition="city=:cityFilterParam)"/>

Can someone please tell me how it makes it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文