如题,将一个组件类Com作为一个实体类A的属性,并在配置文件中以<component>标签配置好了。
public class Com{
private int a;
private int b;
//getter setter ...
}Com com = new Com();
//com初始化
查询的时候,如下的hql语句不能执行
select a from A a where a.com = ?
query.setParameter(0,com);//setParameter方法本上好像就是只能绑定Hibernate Type对象
必须要这样子写
select a from A a where a.com.a = ? and a.com.b = ?
query.setParameter(0,com.getA()).setParameter(1,com.getB());只能这样吗?还是有什么方法按照第一种查询方式来搞?
public class Com{
private int a;
private int b;
//getter setter ...
}Com com = new Com();
//com初始化
查询的时候,如下的hql语句不能执行
select a from A a where a.com = ?
query.setParameter(0,com);//setParameter方法本上好像就是只能绑定Hibernate Type对象
必须要这样子写
select a from A a where a.com.a = ? and a.com.b = ?
query.setParameter(0,com.getA()).setParameter(1,com.getB());只能这样吗?还是有什么方法按照第一种查询方式来搞?
解决方案 »
- 哪位帅哥哥可以逐句详细介绍下面的jsp代码,我给他100分,不够,还可以加呀!偶不胜感激哦
- struts token令牌机制
- 再次发关于:apache.struts2.dispatcher.ServletDispatche
- 求web service 压力测试方法或文章
- java下拉列表问题
- xml 生成word 再把word转成pdf
- Jdom 中 对于多个名字空间,在生成XML文件的时候如何生成这样的根元素?
- Tomcat 5.0 如何配置虚拟目录呀?
- JBuilder6+weblogic编译ejb出现错误,怎么办?
- Struts2使用IF标签判断集合非空无效
- ssh 如何去得当前在线人数?服务器为tomcat 或者 websphere
- 明天面试,求救,急!!!!!!!
这么写
query.setParameter(0,com,Hibernate.OBJECT)的话就没有问题。但直接让Hibernate自己猜测时就出现问题,这是怎么回事呢?
哈哈,sry,例子说得比较简单了。A实体类可以是
class A {
Long id;
Com com;
//getter,setter...
}