表结构nno--------编号
money------金额
rec--------序号
oper-------提交人//hibernate生成类(A)
package cn.hibernate;
public class tjpayrec implements java.io.Serializable {
public tjpayrec() {
}
public tjpayrec(tjpayrecId id) {
this.id = id;
}
public tjpayrecId getId() {
return this.id;
}
public void setId(tjpayrecId id) {
this.id = id;
}
}//hibernate生成类(B)
package cn.hibernate;
import java.sql.Timestamp;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class tjpayrecId implements java.io.Serializable {
private Integer nno;
private Short rec;
private Double money;
private String oper;
public tjpayrecId() {
}
public tjpayrecId(Integer nno, Short rec, Double money) {
this.nno = nno;
this.rec = rec;
this.money = money;
this.oper = oper;
}
public Integer getNno() {
return this.nno;
}..............................代码略.........!!!!!!! @SuppressWarnings("unchecked")
public static Boolean pay(Integer nno) {
try {
Session s1=HibernateSessionFactory.getSession();
Transaction t1=s1.beginTransaction();
Double money;
Short rec;
tjpayrec f2=new tjpayrec();
tjpayrecId f1=new tjpayrecId();
//<<<系统提示:Unknown entity: cn.hibernate.tjpayrecId>>>------------请高手指点一下. money=10.0;
rec=1;
f1.setMoney(money);
f1.setOper("olylai");
f1.setNno(nno);
f1.setRec(rec);
f2.setId(f1);
s1.save(f2.getId());
t1.commit();
return true;
} catch (RuntimeException re) {
throw re;
}
}
money------金额
rec--------序号
oper-------提交人//hibernate生成类(A)
package cn.hibernate;
public class tjpayrec implements java.io.Serializable {
public tjpayrec() {
}
public tjpayrec(tjpayrecId id) {
this.id = id;
}
public tjpayrecId getId() {
return this.id;
}
public void setId(tjpayrecId id) {
this.id = id;
}
}//hibernate生成类(B)
package cn.hibernate;
import java.sql.Timestamp;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class tjpayrecId implements java.io.Serializable {
private Integer nno;
private Short rec;
private Double money;
private String oper;
public tjpayrecId() {
}
public tjpayrecId(Integer nno, Short rec, Double money) {
this.nno = nno;
this.rec = rec;
this.money = money;
this.oper = oper;
}
public Integer getNno() {
return this.nno;
}..............................代码略.........!!!!!!! @SuppressWarnings("unchecked")
public static Boolean pay(Integer nno) {
try {
Session s1=HibernateSessionFactory.getSession();
Transaction t1=s1.beginTransaction();
Double money;
Short rec;
tjpayrec f2=new tjpayrec();
tjpayrecId f1=new tjpayrecId();
//<<<系统提示:Unknown entity: cn.hibernate.tjpayrecId>>>------------请高手指点一下. money=10.0;
rec=1;
f1.setMoney(money);
f1.setOper("olylai");
f1.setNno(nno);
f1.setRec(rec);
f2.setId(f1);
s1.save(f2.getId());
t1.commit();
return true;
} catch (RuntimeException re) {
throw re;
}
}
解决方案 »
- 服务器启动时报No bean named 'sessionFactory' is defined,怎么解决呀
- js 写cookie jsp 为什么读不出(在线等)
- 咨询高人:在项目中的所有查询均使用HQL(实在不支持的例外),是否有其必要性
- 为什么在eclipse中配置struts标签总是出错
- 编写一个Applet,将其所在区域分成大小相等的2X2块,分别装入四幅图片
- 关于MySQL的问题
- 求高手帮忙。passing array to procedur 的问题,代码在里面,在线等!
- 请教《JAVA编程思想》和《JAVA核心技术高级特性》阅读顺序异或建议?
- jboss的jvm bind:8080和Oracle Servlet Engine端口冲突怎么解决?
- 打包后的程序找不到某个方法
- 字符串之间 == 与 euqals 的问题
- 不显示删除回复显示所有回复显示星级回复显示得分回复 超链接下载 压缩包被直接打开问题
<composite-id name="id" class="cn.hibernate.tjpayrecId">
<key-property name="nno" type="string">
<column name="(这里不知道,和你的数据库列匹配)" length="50" />
</key-property>
<key-property name="money" type="Integer">
<column name="(这里不知道,和你的数据库列匹配)" length="50" />
</key-property>
<key-property name="rec" type="string">
<column name="(这里不知道,和你的数据库列匹配)" length="50" />
</key-property>
<key-property name="oper" type="string">
<column name="(这里不知道,和你的数据库列匹配)" length="50" />
</key-property>
</composite-id>
的形式
<class catalog="SPP" name="cn.hibernate.tjpayrec" schema="dbo" table="tjpayrec">
<composite-id class="cn.hibernate.tjpayrecId" mapped="false" name="id" unsaved-value="undefined">
<key-property name="nno" type="java.lang.Integer">
<column name="nno"/>
</key-property>
<key-property name="rec" type="java.lang.Short">
<column name="rec"/>
</key-property>
<key-property name="money" type="java.lang.Double">
<column name="money" precision="10"/>
</key-property>
<key-property name="oper" type="java.lang.String">
<column length="10" name="oper"/>
</key-property>
</composite-id>
</class>
</hibernate-mapping>
在你的hibernate.cfg.xml中+上
<mapping resource="tjpayrec.hbm.xml"/>
应该是这句有问题,再说了你的
package cn.hibernate;
public class tjpayrec implements java.io.Serializable {
public tjpayrec() {
}
public tjpayrec(tjpayrecId id) {
this.id = id;
}
public tjpayrecId getId() {
return this.id;
}
public void setId(tjpayrecId id) {
this.id = id;
}
}
这个类里根本都没有定义tjpayrecId啊
另外不知道是楼主的语法规范差还是工具傻,java类名都是小写字母开头的
看下这个帖子,不知道你是不是同样的问题
我把mppped设置成了true也不行哦.