<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory/MyBlog">
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/hibernate_test
</property>
<property name="hibernate.connection.username">
dbuser
</property>
<property name="hibernate.connection.password">
1234
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="Blog.hbm.xml" />
<mapping resource="BlogItem.hbm.xml" />
</session-factory>
</hibernate-configuration>两个hbm文件如下:
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory/MyBlog">
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/hibernate_test
</property>
<property name="hibernate.connection.username">
dbuser
</property>
<property name="hibernate.connection.password">
1234
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="Blog.hbm.xml" />
<mapping resource="BlogItem.hbm.xml" />
</session-factory>
</hibernate-configuration>两个hbm文件如下:
解决方案 »
- pager-taglib中文乱码问题
- 请大侠远程解决个叼专的乱码问题...
- axis 1.3 获取请求和返回报文时出现编码问题
- 谁帮我看看这段JSTL代码为什么取不出来值
- JDOM处理xml的问题.提示org.jdom不存在
- JAVA有没有System.Web.UI.WebControls类似的类
- 看了很多帖,一直很困惑的问题
- struts标签中的<bean:write>的用法
- 求助:第一次使用WebLogic+Jbuilder建EJB,一个问题困扰我,郁闷中,不能自拔。
- J2se与j2ee之间有什么本质不同吗,j2ee是不是前者的升级版,可不可这样理解?
- jbuilderx的bt问题~~各位高手指点一下拉~~
- struts中新增,编辑页面是如何实现的
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="BlogItem"
table="BLOG_ITEMS"
dynamic-update="true">
<id
name="id"
column="BLOG_ITEM_ID">
<generator class="native"/>
</id>
<property
name="title"
column="TITLE"
not-null="true"/>
<property
name="text"
column="TEXT"
not-null="true"/>
<property
name="datetime"
column="DATE_TIME"
not-null="true"/>
<many-to-one
name="blog"
column="BLOG_ID"
not-null="true"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping>
<class
name="Blog"
table="BLOGS" >
<id
name="id"
column="BLOG_ID">
<generator class="native"/>
</id>
<property
name="name"
column="NAME"
not-null="true"
unique="true"/>
<bag
name="items"
inverse="true"
order-by="DATE_TIME"
cascade="all">
<key column="BLOG_ID"/>
<one-to-many class="BlogItem"/>
</bag>
</class>
</hibernate-mapping>
private SessionFactory _sessions; public void exportTables() throws HibernateException {
Configuration cfg = new Configuration()
.addClass(Blog.class).addClass(BlogItem.class);
new SchemaExport(cfg).create(true, true);
} public static void main(String[] args){
BlogMain obj = new BlogMain();
obj.exportTables();
}
结果就出了如题的错误.请问,hibernate3我的配置有何错误?
用你写的那种方式可能忽略了Hibernate.cfg.xml配置文件,得在程序中调用Configuration.setProperty()来设置属性,
如 new Configuration().setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect")
文件为默认配置文件,要加doConfigure()这样才是选择hibernate.cfg.xml文件为默认配置文件!