我已检查过我的pojo课程,但我无法找到错误。谁能请帮忙。下面是类,映射和配置文件。
我试图在专利和发明人之间建立一对多的关系。以下错误经常弹出。我这次无法解决。
public class Inventor {
private int id;
private String inventor;
private Patent pat;
public Inventor() {
// TODO Auto-generated constructor stub
}
public int getId() {
return id;
}
public String getInventor() {
return inventor;
}
public Patent getPat() {
return pat;
}
public void setId(int id) {
this.id = id;
}
public void setInventor(String inventor) {
this.inventor = inventor;
}
public void setPat(Patent pat) {
this.pat = pat;
}
public Inventor(String inventor, Patent pat) {
// TODO Auto-generated constructor stub
this.inventor=inventor;
this.pat=pat;
}
public Inventor(int id,String inventor, Patent pat) {
// TODO Auto-generated constructor stub
this.id=id;
this.inventor=inventor;
this.pat=pat;
}
public class Patent {
private int id;
private String application_doc_num;
private String application_date;
private String application_country;
private String publication_doc_num;
private String publication_date;
private String publication_country;
private String publication_kind;
private String patent_no;
private String Assignee;
private String Examiner;
private String Agent;
private String Doc_identifier;
private Set<Inventor> inventors=new HashSet<Inventor>();
public Set<Inventor> getInventors() {
return inventors;
}
public void setInventors(Set<Inventor> inventors) {
this.inventors = inventors;
}
public Patent(int id, String Doc_identifier,String publication_date) {
this.id=id;
this.Doc_identifier=Doc_identifier;
this.publication_date=publication_date;
}
public void setPatent_no(String patent_no) {
this.patent_no = patent_no;
}
public void setPublication_country(String publication_country) {
this.publication_country = publication_country;
}
public void setPublication_date(String publication_date) {
this.publication_date = publication_date;
}
public void setPublication_doc_num(String publication_doc_num) {
this.publication_doc_num = publication_doc_num;
}
public void setApplication_country(String application_country) {
this.application_country = application_country;
}
public void setApplication_date(String application_date) {
this.application_date = application_date;
}
public void setApplication_doc_num(String application_doc_num) {
this.application_doc_num = application_doc_num;
}
public String getPatent_no() {
return patent_no;
}
public String getPublication_country() {
return publication_country;
}
public String getPublication_date() {
return publication_date;
}
public String getPublication_doc_num() {
return publication_doc_num;
}
public String getApplication_country() {
return application_country;
}
public String getApplication_date() {
return application_date;
}
public String getApplication_doc_num() {
return application_doc_num;
}
public Patent( String Doc_identifier,String publication_date) {
this.Doc_identifier=Doc_identifier;
this.publication_date=publication_date;
}
public Patent() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDoc_identifier() {
return Doc_identifier;
}
public void setDoc_identifier(String doc_identifier) {
Doc_identifier = doc_identifier;
}
public String getPublication_kind() {
return publication_kind;
}
public void setPublication_kind(String publication_kind) {
this.publication_kind = publication_kind;
}
public String getAgent() {
return Agent;
}
public String getExaminer() {
return Examiner;
}
public void setAgent(String agent) {
Agent = agent;
}
public void setExaminer(String examiner) {
Examiner = examiner;
}
public String getAssignee() {
return Assignee;
}
public void setAssignee(String assignee) {
Assignee = assignee;
}
}
**Config file**
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</property>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<!-- Assume test is the database name -->
<property name="hibernate.connection.url">
jdbc:oracle:thin:@localhost:1521:xe
</property>
<property name="hibernate.connection.username">
system
</property>
<property name="hibernate.connection.password">
****
</property>
<!-- List of XML mapping files -->
<mapping resource="Patent.hbm.xml"/>
<mapping resource="Inventor.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
**Mapping files**
<hibernate-mapping>
<class name="com.stax.Patent" table="system.PATENT">
<meta attribute="class-description">
This class contains the patent detail.
</meta>
<id name="id" type="int" column="pat_id">
<generator class="native"/>
</id>
<set name="inventors" inverse="true" cascade="all">
<key column="inv_pat_id" />
<one-to-many class="com.stax.Inventor"/>
</set>
<property name="Doc_identifier" column="pat_doc_identifier" type="string"/>
<property name="publication_date" column="pat_date" type="string"/>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="com.stax.Inventor" table="system.INVENTOR">
<meta attribute="class-description">
This class contains the inventor records.
</meta>
<id name="id" column="inv_id" type="int">
<generator class="native"/>
</id>
<property name="inventor" column="inv_inventor" type="string"/>
<many-to-one name="patent" class="com.stax.Inventor"
column="inv_pat_id" />
</class>
</hibernate-mapping>