I use
<class name="Topic" table="topic">
.......
<set name="replies" inverse="true" lazy="false" cascade="save-update">
<key column="TOPIC_ID"/>
<one-to-many class="Reply"/>
</set>
</class>
and I have seen replies is not null and have elements in topic.replies
;
Topic topic = topicService.getTopicById(topicId);
ActionContext actionContext = getActionContext();
actionContext.put("topic", topic);
and in JSP:
<s:iterator value="#topic.replies">
<s:property value="title"/>
</s:iterator>
no title display. and then I change my code
Topic topic = topicService.getTopicById(topicId);
ActionContext actionContext = getActionContext();
actionContext.put("replies", topic.getReplies);
in JSP
<s:iterator value="#replies">
<s:property value="title"/>
</s:iterator>
the value of title is displayed.
I don't know why title isn't displayed in first way.
Replies are configured as lazy, so they are not available until you call topic.getReplies
. This is actually initializes the lazy collection via accessing entity's proxy. On the other hand you are trying to use OGNL to access the entity and it find it in other way, so the collection is not initialized.