read-atleap-hibernate部分分析3-Page类

 read-atleap-hibernate部分分析3-Page类

ª Page的结构与Layout的结构大致相同

 

ª 调用函数

List pageFields = contentFieldManager.findIndexedContentFieldByPageUri(identifier,

uri, locale);

public List findIndexedContentFieldByPageUri(String identifier, String uri, String locale) {

        String hql = new StringBuffer("select distinct field from Page page inner join

                page.contentFields field inner join 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_.id as 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_ on page0_.localizable_id=page0__1_.id inner

join field contentfie1_ on page0_.localizable_id=contentfie1_.localizable_id inn

er join field_value contentfie2_ on contentfie1_.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(String uri,

String identifier, String localeIdentifier)

 

ª HQL

©取用户选取语言的显示内容

select value from Page page inner join page.contentFields field inner join field.contentFieldValues value where page.uri = ? and field.identifier = ? and value.contentLocale.identifier = ?

© 取默认语言的显示内容

select value from Page page inner join page.contentFields field inner join field.contentFieldValues value where page.uri = ? and field.identifier = ? and value.contentLocale.defaultInstance = 'T'

 

ª 执行的SQL

Hibernate: select contentfie2_.id as id, contentfie2_.version as version, conten

tfie2_.locale_identifier as locale_i3_, contentfie2_.value as value, contentfie2

_.simple_value as simple_v5_, contentfie2_.field_id as field_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_ on page0_.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外键映射ContentLocaleidentifier主键

        <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 /* if HTML_TYPE */ {

                       content = ConvertUtil.convertToString(contentFieldValue.getValue(), request.getCharacterEncoding());

                   }

ª 主页显示的内容在数据库中存为一条记录

 

ª mysql> select value from field_value where value like '%many problems during%' l

imit 1;

 

ª 数据库中存放的内容:

 

 

|<p><strong><img alt="" hspace="10" src="rw/resource/banner.jpg" align="right" v

space="10"/></strong>Blandware AtLeap is a free Java multilingual CMS (Content M

anagement System) with full-text search engine. Blandware AtLeap is a framework

which allows you to rapidly start your own Web application.</p>

<p>The idea of the AtLeap project is based on my many years&rsquo; experience of

 management in the area of the site development.&nbsp;I hope Blandware AtLeap wi

ll allow you to &quot;leap&quot; many problems during site development which I h

ave already solved.</p>

<p align="right"><i>Project owner: Andrey Grebnev&nbsp; </i></p>

<ul>

    <li>

    <div><strong><font size="2">Use login <em>admin </em>and password <em>passwo

rd</em> to&nbsp;enter into the system 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 with Manager privileges. Manager has some restrict

ions&nbsp;because of&nbsp;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&nbsp; into the system as simple user. </font></strong></div>

    </li>

</ul>

<p><a href="pages/about.do">Read more about AtLeap</a></p> |

 

注:主要代码在com.blandware.atleap.webapp.taglib.core.content. ContentIteratorTag



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值