org.hibernate.AnnotationException: No identifier specified for entityITeye - 凯发娱乐

org.hibernate.AnnotationException: No identifier specified for entityITeye

2019-01-13 13:11:22 | 作者: 吉星 | 标签: 怎么,呈现,这个 | 浏览: 716

org.hibernate.AnnotationException package com.zjkj.domain;rn// default packagernrnimport javax.persistence.AttributeOverride;rnimport javax.persistence.AttributeOverrides;rnimport javax.persistence.Column;rnimport javax.persistence.EmbeddedId;rnimport javax.persistence.Entity;rnimport javax.persistence.FetchType;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.JoinColumns;rnimport javax.persistence.ManyToOne;rnimport javax.persistence.Table;rnrn/**rn * Student entity. @author MyEclipse Persistence Toolsrn */rn@Entityrn@Table(name = student , catalog = zjkj )rnpublic class Student implements java.io.Serializable rnrn // Fieldsrnrn private StudentId id;rn private Teacher teacher;rn private Float score;rnrn // Constructorsrnrn /** default constructor */rn public Student() rn rnrn /** full constructor */rn public Student(StudentId id, Teacher teacher, Float score) rn this.id = id;rn this.teacher = teacher;rn this.score = score;rn rnrn // Property accessorsrn @EmbeddedIdrn @AttributeOverrides(rn @AttributeOverride(name = stuName , column = @Column(name = stuName , nullable = false, length = 30)),rn @AttributeOverride(name = gdate , column = @Column(name = gdate , nullable = false, length = 10)) )rn public StudentId getId() rn return this.id;rn rnrn public void setId(StudentId id) rn this.id = id;rn rnrn @ManyToOne(fetch = FetchType.LAZY)rn @JoinColumns(rn @JoinColumn(name = teName , referencedColumnName = teName , nullable = false, insertable = false, updatable = false),rn @JoinColumn(name = gdate , referencedColumnName = gdate , nullable = false, insertable = false, updatable = false) )rn public Teacher getTeacher() rn return this.teacher;rn rnrn public void setTeacher(Teacher teacher) rn this.teacher = teacher;rn rnrn @Column(name = score , nullable = false, precision = 12, scale = 0)rn public Float getScore() rn return this.score;rn rnrn public void setScore(Float score) rn this.score = score;rn rnrnrnrnrnrnpackage com.zjkj.domain;rn// default packagernrnimport java.util.HashSet;rnimport java.util.Set;rnimport javax.persistence.AttributeOverride;rnimport javax.persistence.AttributeOverrides;rnimport javax.persistence.CascadeType;rnimport javax.persistence.Column;rnimport javax.persistence.EmbeddedId;rnimport javax.persistence.Entity;rnimport javax.persistence.FetchType;rnimport javax.persistence.OneToMany;rnimport javax.persistence.Table;rnrn/**rn * Teacher entity. @author MyEclipse Persistence Toolsrn */rn@Entityrn@Table(name = teacher , catalog = zjkj )rnpublic class Teacher implements java.io.Serializable rnrn // Fieldsrnrn private TeacherId id;rn private String hobby;rn private Set students = new HashSet(0);rnrn // Constructorsrnrn /** default constructor */rn public Teacher() rn rnrn /** minimal constructor */rn public Teacher(TeacherId id) rn this.id = id;rn rnrn /** full constructor */rn public Teacher(TeacherId id, String hobby, Set students) rn this.id = id;rn this.hobby = hobby;rn this.students = students;rn rnrn // Property accessorsrn @EmbeddedIdrn @AttributeOverrides(rn @AttributeOverride(name = teName , column = @Column(name = teName , nullable = false, length = 100)),rn @AttributeOverride(name = gdate , column = @Column(name = gdate , nullable = false, length = 10)) )rn public TeacherId getId() rn return this.id;rn rnrn public void setId(TeacherId id) rn this.id = id;rn rnrn @Column(name = hobby , length = 100)rn public String getHobby() rn return this.hobby;rn rnrn public void setHobby(String hobby) rn this.hobby = hobby;rn rnrn @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = teacher )rn public Set getStudents() rn return this.students;rn rnrn public void setStudents(Set students) rn this.students = students;rn rnrnrnrnrn怎么会呈现这个反常:请帮我修改好rn%%%% Error Creating SessionFactory %%%%rnorg.hibernate.AnnotationException: Mixing nullable and non nullable columns in a property is not allowed: com.zjkj.domain.d.Studentteacherrn at org.hibernate.cfg.Ejb3Column.checkPropertyConsistency(Ejb3Column.java:414)rn at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:1981)rn at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1361)rn at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)rn at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)rn at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)rn at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)rn at com.zjkj.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:71)rn at com.zjkj.util.HibernateSessionFactory.getSession(HibernateSessionFactory.java:54)rn at com.domain.CreateTableTest.test01(CreateTableTest.java:13)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)rn at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)rn at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:236)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表凯发娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章