at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
Caused by: org.xml.sax.SAXParseException: The content of element type "property" must match "(meta*,(column|formula)*,type )".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
此错误是hibernate-cfg.xml配置文件错误(刚开始我是从文档中copy的,而那个是mapping实体类的映射文件)
[html]
< xml version="1.0" >
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
< xml version="1.0" >
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
[html]
Exception in thread "main" org.hibernate.HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
Exception in thread "main" org.hibernate.HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
没有引入oracle驱动
[html]
Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.itmyhome.Teacher
Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.itmyhome.Teacher没有在hibernate.cfg.xml中加入映射
[html]
然后运行:
[html]
Exception in thread "main" org.hibernate.AnnotationException: No identifier specified for entity: com.itmyhome.Teacher
Exception in thread "main" org.hibernate.AnnotationException: No identifier specified for entity: com.itmyhome.Teacher
在BizEntity类上面加上@MappedSuperclass注解 用在实体的继承过程中的父类上。
如果直接再次运行的话 会报错 表或视图不存在
而应用SchemaExport先生成表
hibernate生成的表语句为:
[sql]
drop table T_STUDENT cascade constraints
drop table T_TEACHER cascade constraints
create table T_STUDENT (
id varchar2(255) not null,
name varchar2(255),
score varchar2(255),
primary key (id)
)
create table T_TEACHER (
id varchar2(255) not null,
name varchar2(255),
title varchar2(255),
primary key (id)
)
drop table T_STUDENT cascade constraints
drop table T_TEACHER cascade constraints
create table T_STUDENT (
id varchar2(255) not null,
name varchar2(255),
score varchar2(255),
primary key (id)
)
create table T_TEACHER (
id varchar2(255) not null,
name varchar2(255),
title varchar2(255),
primary key (id)
)
此时再插入一条teacher数据:
[sql]
Hibernate:
insert
into
T_TEACHER
(name, title, id)
values
( , , )
Hibernate:
insert
into
T_TEACHER
(name, title, id)
values
( , , )最终所需jar包
结束