Hibernate version: not sure
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="csns.model.bulletinboard">
<!-- Forum -->
<class name="ForumModel" table="forum">
<id name="id" column="forum_id">
<generator class="native" />
</id>
.....
<list name="topics">
<key column="forum_id" />
<index column="topics_order" />
<one-to-many class="TopicModel" />
</list>
.....
</class>
<!-- Topic -->
<class name="TopicModel" table="topic">
<id name="id" column="topic_id">
<generator class="native" />
</id>
.....
<list name="replies">
<key column="topic_id" />
<index column="replies_order" />
<one-to-many class="RepliesModel" />
</list>
</class>
<!-- Replies -->
<class name="RepliesModel" table="replies">
<id name="id" column="replies_id">
<generator class="native" />
</id>
.....
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:Code:
2008-04-27 16:52:48,015 ERROR ExceptionResolver: could not resolve property: forum_id of: csns.model.bulletinboard.TopicModel [from csns.model.bulletinboard.TopicModel topic where topic.forum_id = ?]; nested exception is org.hibernate.QueryException: could not resolve property: forum_id of: csns.model.bulletinboard.TopicModel [from csns.model.bulletinboard.TopicModel topic where topic.forum_id = ?]
2008-04-27 16:52:48,015 ERROR ExceptionResolver: org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: forum_id of: csns.model.bulletinboard.TopicModel [from csns.model.bulletinboard.TopicModel topic where topic.forum_id = ?]; nested exception is org.hibernate.QueryException: could not resolve property: forum_id of: csns.model.bulletinboard.TopicModel [from csns.model.bulletinboard.TopicModel topic where topic.forum_id = ?]
Caused by: org.hibernate.QueryException: could not resolve property: forum_id of: csns.model.bulletinboard.TopicModel [from csns.model.bulletinboard.TopicModel topic where topic.forum_id = ?]
I'm trying to do a DAO implementation, but it seems that my code below is not working, that's because TopicModel doesn't have forum_id as the property in the hibernate, the forum_id is mapped as one-to-many from the ForumModel. I want to get the list of the topic in which has the same forum_id as the getParameter string that I retrieves..
Code:
@Override
public List getTopicByForumId(String forum_id) {
String query = "from TopicModel topic where topic.forum_id = ?";
return getHibernateTemplate().find(query, forum_id);
}
Thanks a lot!!