论坛首页 Java版 Hibernate

Hibern8IDE工具使用遇到的问题

浏览 3977 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2003-09-15
我下了Hibern8IDE工具包,然后在jbuilder编译运行Hibern8IDE.java以后,按照动画的说明把hbm.xml文件和相应的prop,cfg.xml文件选中,其中,把各个hbm.xml按照说明上说的按cfg.xml上设定的顺序排列好(第4部)
<pre>

Manually:

1 Start it up
2 Press the first "..." button next to the Properties field and find your hibernate.properties file.
3 Optionally press the second "..." button next to the Config field and find your hibernate.cfg.xml file.
4 Now press "Add" to add your hbm.xml files. You can add as much as you want. Remember that the sequence matters. Arrange the files in the order you would add them to Hibernate configuration.
5 When ready, press "Apply" and now you should get a list of classes available to you in the left tree view.
6 Start entering your HQL in the text area (or drag a node from the tree and it will insert the HQL for getting to that path. Note: does not work for Collections yet)
7 Click "Execute Query" in the Query menu
8 Repeat to you are bored..
</pre>
但是,我运行后出现以下错误(jbuilder下):]
net.sf.hibern8ide.Hibern8IDE
net.sf.hibernate.MappingException: Resource: dbdemo/Address.hbm.xml not found
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:272)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:764)
at net.sf.hibern8ide.Hibern8IDE.reconfig(Hibern8IDE.java:130)
at net.sf.hibern8ide.Hibern8IDE$3.configurationChanged(Hibern8IDE.java:383)
at net.sf.hibern8ide.ConfigurationUI$ApplyConfig.actionPerformed(ConfigurationUI.java:245)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

我条时候发现使以下函数中
void reconfig(File configfile, Properties props, List mappings) {

try {
configuration = new Configuration();

configuration = configuration.setProperties(props);

if (configfile != null) {
configuration = configuration.configure(configfile);
}

Iterator hbms = mappings.iterator();

while (hbms.hasNext()) {
File hbm = (File) hbms.next();
configuration = configuration.addFile(hbm.toString());
}

initialize();
} catch (HibernateException e) {
reportException(e);
}

}
的configuration = configuration.configure(configfile);
有错,可是configfile就是为我的cfg.xml的绝对路径啊。
我不知道我哪里用错了。
我的几个hbm.xml文件放在dbdemo的包中,prop和cfg.xml文件和此包放在同一层上。以下是我的两个配置文件,请大家帮忙找找到底是错在那里:
我个人觉得我的map路径没有错阿
hibernate.pro..

###################################
### DB2 Database
###################################
hibernate.connection.driver_class=COM.ibm.db2.jdbc.net.DB2Driver
hibernate.connection.url=jdbc:db2://lj/ji
hibernate.connection.username=db2admin
hibernate.connection.password=1
hibernate.default_schema=db2admin
hibernate.dialect=net.sf.hibernate.dialect.DB2Dialect
hibernate.show_sql=true

###################################
### HypersonicSQL
###################################
#hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
#hibernate.connection.driver_class=org.hsqldb.jdbcDriver
#hibernate.connection.username=sa
#hibernate.connection.password=
#hibernate.connection.url=jdbc:hsqldb:hsql://localhost
#hibernate.show_sql=true


###################################
### Apache DBCP Connection Pool
###################################
hibernate.dbcp.maxActive 100
hibernate.dbcp.whenExhaustedAction 1
hibernate.dbcp.maxWait 120000
hibernate.dbcp.maxIdle 10

## prepared statement cache

hibernate.dbcp.ps.maxActive 100
hibernate.dbcp.ps.whenExhaustedAction 1
hibernate.dbcp.ps.maxWait 120000
hibernate.dbcp.ps.maxIdle 100



hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">


<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory >
<property name="show_sql">true</property>
<property name="use_outer_join">false</property>

<!-- properties for this SessionFactory only -->
<property name="connection.driver_class">COM.ibm.db2.jdbc.net.DB2Driver</property>
<property name="connection.username">db2admin</property>
<property name="connection.password">1</property>
<property name="connection.url">jdbc:db2://lj/ji</property>
<property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>

<!-- Mapping files -->
<mapping resource="dbdemo/Address.hbm.xml"/>
<mapping resource="dbdemo/Book.hbm.xml"/>
<mapping resource="dbdemo/Contact.hbm.xml"/>
<mapping resource="dbdemo/User.hbm.xml"/>
</session-factory>

</hibernate-configuration>
谢谢。


[/url]
   
时间:2003-09-15
Hibernate8IDE下载以后,你只需要hibern8ide.jar和pf-joi-full.jar这两个jar引入到你的JB的依赖的类库中去就行了。

然后在JB中创建一个启动命令,启动该Class:

net.sf.hibern8ide.Hibern8IDE

然后就OK了。不要去编译什么源代码,多余了。
   
0 请登录后投票
时间:2003-09-16
thank,可以了,我按照robbin说的作了一下,发现只可以把hibernate.prop..选中,如果在选上cfg.xml的话,就会说我重复映射User.hbm.xml的问题,不选的话一切ok!不知道大家遇到这个问题没有,我的cfg.xml文件就是上面的。顺便问一下,我如果要在我的jb中把那它们打成exe怎么做,我试了些办法,但是不行。:D
   
0 请登录后投票
时间:2003-09-17
我运行java net.sf.hibern8ide.Hibern8IDE 出现如下异常:
Excepiton in thread "main" java.lang.NoClassDefFoundErr
Hibern8IDE
我已经把 hibern8ide.jar和pf-joi-full.jar加入到classpath
   
0 请登录后投票
时间:2003-09-17
vivisu 写道
我运行java net.sf.hibern8ide.Hibern8IDE 出现如下异常:
Excepiton in thread "main" java.lang.NoClassDefFoundErr
Hibern8IDE
我已经把 hibern8ide.jar和pf-joi-full.jar加入到classpath


要把Hibernate相关类也引入
   
0 请登录后投票
时间:2003-09-17
kk_kkk 写道
thank,可以了,我按照robbin说的作了一下,发现只可以把hibernate.prop..选中,如果在选上cfg.xml的话,就会说我重复映射User.hbm.xml的问题,不选的话一切ok!不知道大家遇到这个问题没有,我的cfg.xml文件就是上面的。顺便问一下,我如果要在我的jb中把那它们打成exe怎么做,我试了些办法,但是不行。:D


是吗?我没用试过,那你就用hibernate.properties好了。

把什么打成exe?
   
0 请登录后投票
时间:2003-09-17
应该把你自己写的程序的目录也包括进来
   
0 请登录后投票
时间:2003-09-17
就是把它做成一个可以独立运行的exe文件啊。这样以后工作起来比较方便吧
   
0 请登录后投票
时间:2003-09-17
JB有这个功能滴
   
0 请登录后投票
时间:2004-12-10
dbdemo/Address.hbm.xml not found
应该是文件的路径设置不对
我也出现过这种问题
   
0 请登录后投票
论坛首页 Java版 Hibernate

跳转论坛: