read-atleap-hibernate部分分析3-Page类
来源:互联网 发布:c语言的科学与艺术 编辑:程序博客网 时间:2024/05/18 02:49
ª Page的结构与Layout的结构大致相同
ª 调用函数
List pageFields =contentFieldManager.findIndexedContentFieldByPageUri(identifier,
uri, locale);
public List findIndexedContentFieldByPageUri(Stringidentifier, Stringuri, String locale) {
Stringhql = new StringBuffer("select distinct field from Page page inner join
page.contentFields field innerjoin field.contentFieldValues value ")
.append("where ").append("field.identifier like '")
.append(StringUtil.dbEncode(identifier)).append("[%]' ")
.append("and page.uri = ? ")
.append("and (value.contentLocale.identifier = ? or
value.contentLocale.defaultInstance= 'T')")
.toString();
ª 执行的SQL
Hibernate: select distinct contentfie1_.idas id, contentfie1_.version as versio
n, contentfie1_.identifier as identifier,contentfie1_.localizable_id as localiz
a4_, contentfie1_.type as type,contentfie1_.internal as internal from page page
0_ inner join localizable page0__1_ onpage0_.localizable_id=page0__1_.id inner
join field contentfie1_ onpage0_.localizable_id=contentfie1_.localizable_id inn
er join field_value contentfie2_ oncontentfie1_.id=contentfie2_.field_id, local
e contentloc3_ where(contentfie1_.identifier like 'body[%]' )and(page0_.uri=? )
and((contentfie2_.locale_identifier=?)or(contentloc3_.default_instance='T' and
contentfie2_.locale_identifier=contentloc3_.identifier))
mysql> select * from field;
+-----+---------+-------------+----------------+------+----------+
| id | version | identifier |localizable_id | type | internal |
+-----+---------+-------------+----------------+------+----------+
| 0| 0 | title | 2 | 0 | T
***************************************************************
Ø ContentFieldValue
ª 调用函数
ContentFieldValue findContentFieldValueByUriAndIdentifierAndLocale(Stringuri,
String identifier, StringlocaleIdentifier)
ª HQL
©取用户选取语言的显示内容
select valuefrom Page page innerjoin page.contentFields field inner join field.contentFieldValues valuewhere page.uri = ? and field.identifier = ? and value.contentLocale.identifier= ?
© 取默认语言的显示内容
select value from Page pageinner join page.contentFields field inner join field.contentFieldValues valuewhere page.uri = ? and field.identifier = ? and value.contentLocale.defaultInstance= 'T'
ª 执行的SQL
Hibernate: select contentfie2_.id as id, contentfie2_.versionas version, conten
tfie2_.locale_identifieras locale_i3_, contentfie2_.value as value,contentfie2
_.simple_valueas simple_v5_, contentfie2_.field_id asfield_id, contentfie2_.la
st_updated as last_upd7_ from page page0_ inner join localizable page0__1_ on pa
ge0_.localizable_id=page0__1_.id inner join field contentfie1_ onpage0_.localiz
able_id=contentfie1_.localizable_id inner join field_value contentfie2_on conte
ntfie1_.id=contentfie2_.field_id where (page0_.uri=? )and(contentfie1_.identifie
r=? )and(contentfie2_.locale_identifier=?)
ª ContentLocale.hbm.xml中的ContentFieldValue的映射关系
<bag
name="contentFieldValues"
lazy="true"
inverse="true"
cascade="delete"
>
<key
column="locale_identifier"
>
</key>
<one-to-many
class="com.blandware.atleap.model.core.ContentFieldValue"
/>
</bag>
ª ContentFieldValue外键映射ContentLocale的identifier主键
<id
name="identifier"
column="identifier"
type="java.lang.String"
unsaved-value="null"
>
ª contentFieldValue中存放着主要的显示信息
if ( contentField.getType()== ContentField.LINE_TYPE) {
content = contentFieldValue.getSimpleValue();
} else if( contentField.getType()== ContentField.MULTILINE_TYPE) {
content = ConvertUtil.convertToString(contentFieldValue.getValue(),request.getCharacterEncoding());
} else /* ifHTML_TYPE */ {
content = ConvertUtil.convertToString(contentFieldValue.getValue(),request.getCharacterEncoding());
}
ª 主页显示的内容在数据库中存为一条记录
ª mysql> select value fromfield_value where value like '%many problems during%' l
imit 1;
ª 数据库中存放的内容:
|<p><strong><imgalt="" hspace="10" src="rw/resource/banner.jpg"align="right" v
space="10"/></strong>BlandwareAtLeap is a free Java multilingual CMS (Content M
anagement System) with full-text searchengine. Blandware AtLeap is a framework
which allows you to rapidly start your ownWeb application.</p>
<p>The idea of the AtLeap project isbased on my many years’ experience of
management in the area of the sitedevelopment. I hope Blandware AtLeap wi
ll allow you to "leap"many problems during site development which I h
ave already solved.</p>
<palign="right"><i>Project owner: Andrey Grebnev </i></p>
<ul>
<li>
<div><strong><font size="2">Use login<em>admin </em>and password <em>passwo
rd</em> to enter into thesystem with Administrator privileges.</font></str
ong></div>
</li>
<li>
<div><strong><font size="2">Use login<em>manager</em> and password <em>pass
word</em> to enter the system withManager privileges. Manager has some restrict
ions because of his role.</font></strong></div>
</li>
<li>
<div><strong><font size="2">Use login<em>user</em> and password <em>passwor
d</em> to enter into thesystem as simple user. </font></strong></div>
</li>
</ul>
<p><ahref="pages/about.do">Read more about AtLeap</a></p> |
注:主要代码在com.blandware.atleap.webapp.taglib.core.content. ContentIteratorTag中
- read-atleap-hibernate部分分析3-Page类
- read-atleap-hibernate部分分析2-Field类
- read-atleap-hibernate部分分析1-Layout
- read-atleap-Hibernate部分分析2-CreateNews
- read-Atleap-10-主业务分析-ContentField类-Hibernate多对一关系实施案例
- read-Atleap-11-主业务分析-NewsItem类-Hibernate继承关系实施案例
- read-Atleap-9-新闻实体hibernate关系代码分析
- read-Atleap-3-Tiles学习
- read-Atleap-6-发表新闻-新闻实体类
- read-Atleap-1-数据库结构
- read-Atleap-4-标志库的使用
- read-Atleap-5-发表新闻-表现层
- read-Atleap-7-发表新闻-主逻辑
- read-Atleap-8-实做ContentField
- read 系统调用剖析 (vfs分析 address_space page cache)
- read 系统调用剖析 (vfs分析 address_space page cache)
- read 系统调用剖析 (vfs分析 address_space page cache)
- read-Atleap-2-动态改变页面显示语言
- 经常出现的一道C#笔试题
- Dirty Approach之无招胜有招
- [转]C#面试题
- read-atleap-hibernate部分分析2-Field类
- [转]我在上海的五年奋斗岁月
- read-atleap-hibernate部分分析3-Page类
- yahoo中国 最近的笔试题目之 cpp二则。
- 发布Java手机软件《个人消费管理 v1.0》测试版,征求测试中……
- JavaScript中的类继承
- JavaScript中的类继承
- cvs常用命令
- 2005-11-23(晴)
- J2EE体系结构
- 常见图片尺寸大小(厘米 cm,象素 px)