日期:2014-05-20 浏览次数:21159 次
%%%% Error Creating SessionFactory %%%% org.hibernate.MappingException: Repeated column in mapping for entity: com.zzx.pojos.course column: cno (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575) at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:597) at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:615) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405) at org.hibernate.mapping.RootClass.validate(RootClass.java:192) at org.hibernate.cfg.Configuration.validate(Configuration.java:984) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169) at com.zzx.hbm.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31) at com.zzx.test.BagTest.main(BagTest.java:17) %%%% Error Creating SessionFactory %%%% org.hibernate.MappingException: Could not read mappings from resource: com/zzx/pojos/course.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:485) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390) at org.hibernate.cfg.Configuration.configure(Configuration.java:1310) at com.zzx.hbm.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69) at com.zzx.hbm.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53) at com.zzx.test.BagTest.main(BagTest.java:17) Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.zzx.pojos.course at org.hibernate.cfg.Mappings.addClass(Mappings.java:118) at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154) at org.hibernate.cfg.Configuration.add(Configuration.java:386) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427) at org.hibernate.cfg.Configuration.addResource(Configuration.java:482) ... 8 more java.lang.NullPointerException at com.zzx.test.BagTest.main(BagTest.java:20)
drop database if exists joblog; create database joblog CHARSET=gbk; use joblog; drop table if exists student; create table student( id int unsigned not null auto_increment comment 'id', sno int unsigned not null default '0' comment '学号', sname varchar(45) default null comment '姓名', ssex char(2) default null COMMENT '性别', sdept varchar(10) DEFAULT null comment '部门', sage int unsigned default null comment '年龄', saddress varchar(45)default null comment '籍贯', primary key (id) )charset = gbk; drop table if exists course ; create table course( id int unsigned not null auto_increment comment 'id', cno int unsigned default null comment '课程号', cname varchar(45) default null comment '课程名', ccredit int unsigned null comment '学分', primary key (id) ) charset =gbk;
public class course implements java.io.Serializable { private Integer id; private Integer cno; private String cname; private Integer ccredit; private student stu;
public class student implements java.io.Serializable { private Integer id; private Integer sno; private String sname; private String ssex; private String sdept; private Integer sage; private String saddress; private List course=new ArrayList();