hibernate 操作数据库视图
1.在数据库中创建视图:
sql server 的数据库创建都很简单,因为有模板,点击开来只需要勾选就好,
或者命令创建 也很简单
如:
USE [MFDB]
GO
/****** 对象: View [dbo].[view_ul] 脚本日期: 10/30/2013 16:45:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[view_ul]
AS
SELECT dbo.tt_user.id, dbo.tt_user.name, dbo.tt_user.password, dbo.tt_user_log.log_id, dbo.tt_user_log.remark
FROM dbo.tt_user INNER JOIN
dbo.tt_user_log ON dbo.tt_user.id = dbo.tt_user_log.user_id
GO
GO
/****** 对象: View [dbo].[view_ul] 脚本日期: 10/30/2013 16:45:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[view_ul]
AS
SELECT dbo.tt_user.id, dbo.tt_user.name, dbo.tt_user.password, dbo.tt_user_log.log_id, dbo.tt_user_log.remark
FROM dbo.tt_user INNER JOIN
dbo.tt_user_log ON dbo.tt_user.id = dbo.tt_user_log.user_id
GO
其中呢 ,可以设置很多关系--自己去配置吧
2.hibernate 对视图进行映射 --把视图当做一张表来配置映射文件就好
3.调用:对我们映射好的表按常规进行操作就好。。。