ERROR - Servlet.service() for servlet default threw exception
org.hibernate.QueryException: could not resolve property: account_id of: com.rhsw.webcall.model.User [from com.rhsw.webcall.model.User as u,com.rhsw.webcall.model.Account as a where u.account_id = '123' and u.cus_name = 'BaseModel'and u.account_id = a.account_id]是不是我的配置文件出问题了。这是我的用户表
<many-to-one name="account" class="com.rhsw.webcall.model.Account">
<column name="account_id" not-null="true" />
</many-to-one> 账号表。。
<set name="users" inverse="true">
<key>
<column name="account_id" not-null="true" />
</key>
<one-to-many class="com.rhsw.webcall.model.User" />
</set>不知道问题,大家帮忙看看
org.hibernate.QueryException: could not resolve property: account_id of: com.rhsw.webcall.model.User [from com.rhsw.webcall.model.User as u,com.rhsw.webcall.model.Account as a where u.account_id = '123' and u.cus_name = 'BaseModel'and u.account_id = a.account_id]是不是我的配置文件出问题了。这是我的用户表
<many-to-one name="account" class="com.rhsw.webcall.model.Account">
<column name="account_id" not-null="true" />
</many-to-one> 账号表。。
<set name="users" inverse="true">
<key>
<column name="account_id" not-null="true" />
</key>
<one-to-many class="com.rhsw.webcall.model.User" />
</set>不知道问题,大家帮忙看看
可能是你的User表里没有account_id这个地段吧,或者是你这个字段是一个KEY对象,但是你在写hql语句的时候没有正确的引用
你的User PO里是不是有个Account_ID的对象啊?
User对象
private String cus_id;
private Account account;
private String pro_id;
Account对象 private String account_id;
private Set users = new HashSet();
<class name="com.rhsw.webcall.model.User" table="webcall_customer_information">
<id name="cus_id" type="java.lang.String">
<column name="CUS_ID" />
<generator class="uuid.hex" />
</id>
<property name="cus_name" type="java.lang.String">
<column name="CUS_NAME" length="50"/>
</property>
<property name="cus_pws" type="java.lang.String">
<column name="CUS_PWS" length="50"/>
</property>
<property name="tel_ext" type="java.lang.String">
<column name="TEL_EXT" length="50"/>
</property>
<property name="answer_num" type="java.lang.String">
<column name="ANSWER_NUM" length="50"/>
</property>
<property name="answer_way" type="java.lang.String">
<column name="ANSWER_WAY" length="50"/>
</property>
<property name="call_time" type="java.sql.Time">
<column name="CALL_TIME" />
</property>
<property name="state" type="java.lang.String">
<column name="STATE" length="50"/>
</property>
<property name="cus_email" type="java.lang.String">
<column name="CUS_EMAIL" length="50"/>
</property>
<property name="is_admin" type="java.lang.String">
<column name="IS_ADMIN" length="50"/>
</property>
<property name="pro_id" type="java.lang.String">
<column name="PRO_ID" length="50"/>
</property>
<many-to-one name="account" class="com.rhsw.webcall.model.Account">
<column name="ACCOUNT_ID" not-null="true" />
</many-to-one>
<id name="account_id" type="java.lang.String">
<column name="ACCOUNT_ID" />
<generator class="uuid.hex" />
</id>
<property name="account_name" type="java.lang.String">
<column name="ACCOUNT_NAME" length="50" />
</property>
<property name="account_password" type="java.lang.String">
<column name="ACCOUNT_PASSWORD" length="50" />
</property>
<property name="company_id" type="java.lang.String">
<column name="COMPANY_ID" length="50" />
</property>
<property name="manage_id" type="java.lang.String">
<column name="MANAGE_ID" length="50" />
</property>
<set name="users" inverse="true">
<key>
<column name="account_id" not-null="true" />
</key>
<one-to-many class="com.rhsw.webcall.model.User" />
</set>
</class>
得这样写吧
u.account = '123' and u.cus_name = 'BaseModel'and u.account = a.account_id
where u.account.account_id = '123' 可以结贴了