hibernate 学习笔记三

ORM映射详解
本文深入探讨了ORM技术中不同类型的集合映射策略,包括高级映射、组件映射及继承映射等,并详细介绍了每种映射方式在表结构、类定义及映射文件上的实现细节。
高级映射
-----------------
集合类映射
Set
表上:
table item table image
id<PK> item_id<FK><PK>
name filename<PK>
类上:
class Item
id
name
Set
映射文件上:
Item.hbm.xml
<set name = "images" table = "hedong_image">
<key column = "item_id"/>
<element type = "string" column = "filename" not-null = "true"/>
</set>
lazy
可以设置Hibernate关联表中信息的加载策略
true:采用延迟加载
false:不采用延迟加载
如果采用延迟加载,在session关闭后还想进行操作可以使用Hibernate.initialize()进行预加载
Bag
表上:
table item table image
id<PK> id<PK>
name filename
item_id<FK>
类上:
class Item
id
name
List
映射文件上:
Item.hbm.xml
<idbag name="images" table = "hedong_image_bag" >
<collection-id type="int" column="id">
<generator class="increment"></generator>
</collection-id>
<key column = "item_id"></key>
<element type="string" column = "filename"></element>
</idbag>
List
表上:
table item table image
id<PK> item_id<FK,PK>
name filename
position<PK>

类上:
class Item
id
name
List
映射文件上:
Item.hbm.xml
<list name = "images" table = "hedong_image_list>
<key column = "item_id"/>
<index column = "position"/>
<element type = "string" column = "filename"/>
</list>
Map
表上:
table item table image
id<PK> item_id<FK,PK>
image_name<PK>
name filename


类上:
class Item
id
name
Map
映射文件上:
Item.hbm.xml
<map name="images" table = "hedong_image_map" order-by = "image_name">
<key column = "item_id"></key>
<index column = "image_name" type = "string"/>
<element type="string" column = "filename"></element>
</map>

组件映射(component)
有关联关系的多个POJO类映射到一张表上

继承映射

是否支持多态 更新维护是否方便 出具报表是否方便
每个子类一张表 No No Yes

整个类层次一张表 Yes No Yes

每个类一张表 Yes Yes No
1、每个子类一张表
表上:
create table hedong_cash_payment(
payment_id number(7) primary key,
amout number
);
create table hedong_credit_payment(
payment_id number(7) primary keym
amout number,
cardtype varchar2(20)
);
create table hedong_cheque_payment(
payment_id number(7) primary key,
amout number,
chequeno number
);
类上:
Payment CashPayment CreditPayment ChequePayment
映射文件上:
com.briup.sixth.concrete.Payment.hbm.xml
2、整个类层次一张表
表上:
create table hedong_payment(
payment_id number(7) primary key,
amount number,
cardtype varchar2(20),
chequeno number,
paytype varchar2(10)
);
类上:
Payment CashPayment CreditPayment ChequePayment
映射文件上:
com.briup.sixth.hierarchy.Payment.hbm.xml

Hibernate对集合元素排序
1、sort:在内存中排序
sort = "natural":按ASCII码值排序
2、order-by:在数据库中排序
order-by = "字段名"
内容概要:本文介绍了一个基于多传感器融合的定位系统设计方案,采用GPS、里程计和电子罗盘作为定位传感器,利用扩展卡尔曼滤波(EKF)算法对多源传感器数据进行融合处理,最终输出目标的滤波后位置信息,并提供了完整的Matlab代码实现。该方法有效提升了定位精度与稳定性,尤其适用于存在单一传感器误差或信号丢失的复杂环境,如自动驾驶、移动采用GPS、里程计和电子罗盘作为定位传感器,EKF作为多传感器的融合算法,最终输出目标的滤波位置(Matlab代码实现)机器人导航等领域。文中详细阐述了各传感器的数据建模方式、状态转移与观测方程构建,以及EKF算法的具体实现步骤,具有较强的工程实践价值。; 适合人群:具备一定Matlab编程基础,熟悉传感器原理和滤波算法的高校研究生、科研人员及从事自动驾驶、机器人导航等相关领域的工程技术人员。; 使用场景及目标:①学习和掌握多传感器融合的基本理论与实现方法;②应用于移动机器人、无人车、无人机等系统的高精度定位与导航开发;③作为EKF算法在实际工程中应用的教学案例或项目参考; 阅读建议:建议读者结合Matlab代码逐行理解算法实现过程,重点关注状态预测与观测更新模块的设计逻辑,可尝试引入真实传感器数据或仿真噪声环境以验证算法鲁棒性,并进一步拓展至UKF、PF等更高级滤波算法的研究与对比。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值