Hibernate报错:could not resolve property
代码如下publicstaticListtype(Stringusername){//返回用户类型Configurationconfig=newConfiguration...
代码如下
public static List type(String username){ //返回用户类型
Configuration config=new Configuration().configure();
SessionFactory sf=config.buildSessionFactory();
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
String str=new String();
str="select login.cloginType from Logininfo as login where login.cloginId='"+username+"'";
Query query=session.createQuery(str);
List list=query.list();
tx.commit();
tx=null;
session.close();
return list;
}
Hibernate配置
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.library.pojo.Logininfo" table="logininfo" catalog="library">
<id name="cloginId" type="java.lang.String">
<column name="cLoginID" length="20" />
<generator class="assigned" />
</id>
<property name="cloginPwd" type="java.lang.String">
<column name="cLoginPwd" length="20" not-null="true" />
</property>
<property name="iloginType" type="java.lang.Integer">
<column name="iLoginType" not-null="true" />
</property>
</class>
</hibernate-mapping>
运行是出现could not resolve property请问是哪错了。谢谢 展开
public static List type(String username){ //返回用户类型
Configuration config=new Configuration().configure();
SessionFactory sf=config.buildSessionFactory();
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
String str=new String();
str="select login.cloginType from Logininfo as login where login.cloginId='"+username+"'";
Query query=session.createQuery(str);
List list=query.list();
tx.commit();
tx=null;
session.close();
return list;
}
Hibernate配置
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.library.pojo.Logininfo" table="logininfo" catalog="library">
<id name="cloginId" type="java.lang.String">
<column name="cLoginID" length="20" />
<generator class="assigned" />
</id>
<property name="cloginPwd" type="java.lang.String">
<column name="cLoginPwd" length="20" not-null="true" />
</property>
<property name="iloginType" type="java.lang.Integer">
<column name="iLoginType" not-null="true" />
</property>
</class>
</hibernate-mapping>
运行是出现could not resolve property请问是哪错了。谢谢 展开
3个回答
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
展开全部
用a.user.id。
例如你那句话写成:
1List<Article> articles=(List<Article>)hibernateTemplate.find("from Ariticle a where a.user.id='"+id+"'");
例如你那句话写成:
1List<Article> articles=(List<Article>)hibernateTemplate.find("from Ariticle a where a.user.id='"+id+"'");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你那貌似many to one 的主外键关系,可能是外没有找到主
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询