补充下,页面显示的记录是按照一定查询条件从表中检索出的,但是a、b、c三表的检索策略基本相同
解决方案 »
- 进行dom4j解析读取文件,如下
- hibernate连接oracle提示Unknow entity错误
- 求救,myeclipse hibernate reverse engineering 生成的主键类型可以配置吗?
- SSH整合 User Libraries 不起作用!!(速度帮忙!)
- hibernate反向生成出错,求解呀
- java开源项目大全改版
- 请教如何解决tomcat5.5显示html页面时出现中文乱码?
- JBOSS,datasource jndi,数据源配置没有问题,但我在HttpServlet的init方法中不能lookup datasource
- struts1.1中logic标签的使用问题。急!
- 请问谁知道java应用程序去掉右上角的关闭菜单。
- 怎样才能杀掉threadpool中的thread
- tomcat 到底什么时候需重起?
B表F1,F2,F3
C表F1,F2,F3CREATE VIEW abc
AS
(SELECT F1,F2,F3 from A) UNION (SELECT F1,F2,F3 from B) UNION (SELECT F1,F2,F3 from C)然后操作视图就和操作普通表一样
create or replace view V_$Worker as
select rnum,oper,opername,opdate from(
select rnum,rfillope as oper,rfillopename as opername,rfilldate as opdate
from relic where (rfillope is not null or rfillope <> '') and (rfilldate is noy null)
union all
select rnum,wfillope as oper,wfillopename as opername,wfilldate as opdate
from wound where (wfillope is not null or wfillope <> '') and (wfilldate is noy null)
union all
select rnum,cfillope as oper,cfillopename as opername,cfilldate as opdate
from catalog where (cfillope is not null or cfillope <> '') and (cfilldate is noy null)
union all
select rnum,vfillope as oper,vfillopename as opername,vfilldate as opdate
from verify where (vfillope is not null or vfillope <> '') and (vfilldate is noy null)
union all
select rnum,jfillope as oper,jfillopename as opername,jfilldate as opdate
from judge where (jfillope is not null or jfillope <> '') and (jfilldate is noy null)
union all
select rnum,rauditope as oper,rauditopename as opername,rauditdate as opdate
from relic where (rauditope is not null or rauditope <> '') and (rauditdate is noy null)
union all
select rnum,wauditope as oper,wauditopename as opername,wauditdate as opdate
from wound where (wauditope is not null or wauditope <> '') and (wauditdate is noy null)
union all
select rnum,cauditope as oper,cauditopename as opername,cauditdate as opdate
from catalog where (cauditope is not null or cauditope <> '') and (cauditdate is noy null)
union all
select rnum,vauditope as oper,vauditopename as opername,vauditdate as opdate
from verify where (vauditope is not null or vauditope <> '') and (vauditdate is noy null)
union all
select rnum,jauditope as oper,jauditopename as opername,jauditdate as opdate
from judge where (jauditope is not null or jauditope <> '') and (jauditdate is noy null)
union all
)
你参考下这个视图创建语句看有帮助没。
像我这样的情况视图是事先创建好还是在程序当中创建呢。。?视图当中的数据是在什么时候导入的呢?再拿sureyor举的那个例子说下,
A表F1,F2,F3
B表F1,F2,F3,F4
C表F1,F2,
从各个基表中取出的列可能会略有不同,如果是这种情况呢?能够取各个表列的最大集合么。。?没有的列就默认为空?
create or replace view view_A_B_C
as (
select a.字段, ... from A a where ...
union all
select b.字段, ... from B b where ...
union all
select c.字段, ... from C c where ...
)
貌似这个问题从数据库着手是无解了。。
A表F1,F2,F3
B表F1,F2,F3,F4
C表F1,F2,
从各个基表中取出的列可能会略有不同,如果是这种情况呢?能够取各个表列的最大集合么。。?没有的列就默认为空?
--------------------------
for examle
select a.f1, a.f2, a.f3, "a.dummy" --这里用空字符串""也可以,或者用其他提示也可以,自己决定,总之,把列补齐就行
from a
where xxx
union all
select b.f1, b.f2, b.f3, b.f4
from b
where xxx
union all
select c.f1, c.f2, "c.dummy1", "c.dummy2"
from c
where xxx
AS
(SELECT F1,F2,F3,'' F4 from A) UNION
(SELECT F1,F2,F3,F4 from B) UNION
(SELECT F1,F2,'' F3,'' F4 from C) 这样abc视图就有四个字段F1,F2,F3,F4,当然上面的默认值''可以根据你实际的需要来自行设置
方法2: 取出来放到一个List里,要求每个对象应该有相同的页面列表需要的get方法(如果记录不是太多)
有三个子类a,b,c
看子类的私有属性多不多 不多的话就只设一张x表 subclass
多的话设4张表 joined-subclass
这样取起来就很容易
毕竟太依赖数据库 以后维护 移植的风险要大很多
看看.也许你能够得到帮助的!
而且查询视图跟查询表的结果完全一样
只要你不做insert update delete 操作即可