从两个表访问数据 [英] access data from two table

查看:75
本文介绍了从两个表访问数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户类具有与客户表中的名称字段相对应的名称属性. 客户类还定义用于放置fieldName和fieldValue的地图.

Customer class have name property that corresponds to name field in customer table. Customer class also define the map that use for put the fieldName and fieldValue.

在数据库中,在客户表中定义客户名称,并在表单表中定义字段值. 现在,我如何从客户表中检索客户名,从表单表中检索字段值. 在hbm文件中:

on database customer name define in customer table and fieldvalue define in form table. now how i can retrieve customer name from customer table and fieldvalue from form table. in hbm file:

<map name="formFields" table="form" cascade="all-delete-orphan" lazy="true">
    <key column="id"/>
    <index column="fieldName" type="string"/>
    <element column="fieldValue" type="string"/>
 </map>

我想显示两个项目. 我有一个类别,第一项是同一类别中的属性,第二项被定义为同一类别中map函数中的映射键的映射值.两项均在单独的表上定义.如何显示两个项目

i want display two items. i have one class, first item is property in same class and second item is define as a map value of a map key in map function in same class. both items are defined on separately tables. how display both the items

推荐答案

请勿这样做.只是

  • 创建实体类Form
  • CustomerForm
  • 之间的hbm.xml中定义one-to-one关系
  • 在您的Customer类中创建属性Form form
  • 在DAO中定义一个方法或将其返回给您的namevalue作为映射的任何方法.
  • create a entity class Form
  • define a one-to-one relationship in your hbm.xml, between Customer and Form
  • create a property Form form in your Customer class
  • define a method in your DAO or whatever to return you name and value as a map.

这篇关于从两个表访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆