我有一个hibernate类question 和answer
建立好双向多对一以后
代码片段如下:question:
<set name="ballotAnswer" cascade="all">
<key column="b_q_id"></key>
<one-to-many class="hibernate.BallotAnswer"/>
</set>
answer:
<many-to-one name="ballotQuestion" column="b_q_id" class="hibernate.BallotQuestion" lazy="false" fetch="select" ></many-to-one>
做查询的代码如下:
int id = new Integer(request.getParameter("id"));
AbstractView av = new AbstractView();
Iterator it = av.getSelectItem("from BallotAnswer where BAId="+id).iterator();
BallotAnswer ba= (BallotAnswer)it.next();
int count = ba.getBACount();
count = count+1;
ba.setBACount(count);
BallotQuestion bq = ba.getBallotQuestion();
System.out.println(bq.getBQAuthor());
BallotAnswer里的值我可以取道,但是BallotQuestion里的值报空
建立好双向多对一以后
代码片段如下:question:
<set name="ballotAnswer" cascade="all">
<key column="b_q_id"></key>
<one-to-many class="hibernate.BallotAnswer"/>
</set>
answer:
<many-to-one name="ballotQuestion" column="b_q_id" class="hibernate.BallotQuestion" lazy="false" fetch="select" ></many-to-one>
做查询的代码如下:
int id = new Integer(request.getParameter("id"));
AbstractView av = new AbstractView();
Iterator it = av.getSelectItem("from BallotAnswer where BAId="+id).iterator();
BallotAnswer ba= (BallotAnswer)it.next();
int count = ba.getBACount();
count = count+1;
ba.setBACount(count);
BallotQuestion bq = ba.getBallotQuestion();
System.out.println(bq.getBQAuthor());
BallotAnswer里的值我可以取道,但是BallotQuestion里的值报空
解决方案 »
- 求助,struts2的convention-plugin配置
- 关于struts页面初始化赋值
- javascript如何获取jsp中的Collection!急!急!急!急!急!急!急!
- 关于JFreeChart横轴子标题的竖直显示问题 急
- 求正则表达式匹配网址
- Myeclipse+mysql模式的web开发问题
- 菜鸟新手,在ssh框架在调试过程中出现如下问题,请高手搭救!
- httpclient post问题
- 怎么点击radio就提交form,不用按"提交按钮"?
- 请指点 同一页面多按钮 点击分别转到其他页面 里面有图 谢谢
- 复选框——单选框取数据库值问题!!!!hibernate+struts2!
- Intellij 导入sqlserver驱动问题
确认下是否查到数据了??
<key column="b_q_id"> </key>
<one-to-many class="hibernate.BallotAnswer"/>
</set> 你没设置给它 那里来的值