该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2004-03-26
上面的问题已经解决,
可是插不了数据进入表: 2004-3-26 22:01:58 net.sf.hibernate.cfg.Environment <clinit> 信息: Hibernate 2.1.2 2004-3-26 22:01:59 net.sf.hibernate.cfg.Environment <clinit> 信息: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.query.imports=net.sf.hibernate.test, net.sf.hibernate.eg, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK, hibernate.show_sql=false, hibernate.connection.password=01022112, hibernate.statement_cache.size=25, hibernate.connection.pool_size=1} 2004-3-26 22:01:59 net.sf.hibernate.cfg.Environment <clinit> 信息: using java.io streams to persist binary types 2004-3-26 22:01:59 net.sf.hibernate.cfg.Environment <clinit> 信息: using CGLIB reflection optimizer 2004-3-26 22:01:59 net.sf.hibernate.cfg.Configuration addClass 信息: Mapping resource: hiberante/PersonModel.hbm.xml 2004-3-26 22:02:01 net.sf.hibernate.cfg.Binder bindRootClass 信息: Mapping class: hiberante.PersonModel -> ZY_PERSON 2004-3-26 22:02:01 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing one-to-many association mappings 2004-3-26 22:02:01 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing one-to-one association property references 2004-3-26 22:02:01 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing foreign key constraints 2004-3-26 22:02:01 net.sf.hibernate.dialect.Dialect <init> 信息: Using dialect: net.sf.hibernate.dialect.MySQLDialect 2004-3-26 22:02:01 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use outer join fetching: true 2004-3-26 22:02:01 net.sf.hibernate.connection.DriverManagerConnectionProvider configure 信息: Using Hibernate built-in connection pool (not for production use!) 2004-3-26 22:02:01 net.sf.hibernate.connection.DriverManagerConnectionProvider configure 信息: Hibernate connection pool size: 1 2004-3-26 22:02:01 net.sf.hibernate.connection.DriverManagerConnectionProvider configure 信息: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK 2004-3-26 22:02:01 net.sf.hibernate.connection.DriverManagerConnectionProvider configure 信息: connection properties: {user=root, password=01022112} 2004-3-26 22:02:01 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) 2004-3-26 22:02:02 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use scrollable result sets: true 2004-3-26 22:02:02 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use JDBC3 getGeneratedKeys(): false 2004-3-26 22:02:02 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: false 2004-3-26 22:02:02 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {no='N', true=1, yes='Y', false=0} 2004-3-26 22:02:02 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: cache provider: net.sf.ehcache.hibernate.Provider net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:133) at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748) at hiberante.TestPersonModel2.main(TestPersonModel2.java:33) Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.hibernate.Provider at java.net.URLClassLoader$1.run(URLClassLoader.java:198) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:299) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265) at java.lang.ClassLoader.loadClass(ClassLoader.java:255) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:140) at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:86) at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:130) ... 3 more 2004-3-26 22:02:02 net.sf.hibernate.connection.DriverManagerConnectionProvider close 信息: cleaning up connection pool: jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK Exception in thread "main" |
|
返回顶楼 | |
发表时间:2004-03-27
信息: no JNDI name configured
java.lang.NoClassDefFoundError: javax/transaction/Synchronization at net.sf.hibernate.impl.Sessi |
|
返回顶楼 | |
发表时间:2004-06-21
这个例子代码中下面这段是存在较大性能问题的:
/*-------添加1000条记录时间--------------*/ long start = System.currentTimeMillis(); for(int i = 0; i < 1000; i ++) { Message message = new Message("hello"); session.save(message); session.flush(); } 大家把循环次数改为10000和100000试试,看看花了多少时间? 以下是我机器上的数据(P4 2G+512M+MySQL,和例子程序都运行在一台PC上): 循环次数: 1,000 10,000 100,000 所花时间: 2.25s 134.14s 等了15分钟,等不了了 不要怀疑MySQL,只要把session.flush(); 这一句移到循环外面,就有以下结果: 循环次数: 1,000 10,000 100,000 所花时间: 0.86s 5.75s 47.734s 我刚开始学,所以我更觉得越是给初学者看的,越要保证正确性,否则会误导一大批! |
|
返回顶楼 | |
发表时间:2004-06-21
不好意思,放错地方了。
|
|
返回顶楼 | |
发表时间:2004-11-26
我自己先建立了个表,里面就userid,和name两个字段,我现在就报这个错。2004-11-26 15:26:26 net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(10) The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))". net.sf.hibernate.MappingException: Error reading resource: test/Name.hbm.xml at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:336) at test.TestName.main(TestName.java:27) 我的xml是这样写的。 <?xml version="1.0" encoding="GB2312"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <class name="test.Name" table="ZY.name"> <property name="userid"/> <property name="name"/> </class> </hibernate-mapping> 我自己在程序理设置id不行吗,要是不行的话,我怎么改呀。 |
|
返回顶楼 | |
发表时间:2004-11-26
引用 <?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <class name="test.Name" table="ZY.name"> <property name="userid"/> <property name="name"/> </class> </hibernate-mapping> 修改为: <?xml version="1.0" encoding="GB2312"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="test.Name" table="ZY.name"> <id column="userid" name="userid" type="integer"> <!-- 主键生成有程序指定 --> <generator class="assigned"/> </id> <property name="name" type="string"/> </class> </hibernate-mapping> 必须指定ID属性 |
|
返回顶楼 | |
发表时间:2004-11-29
谢谢,我现在又有个问题,我装的是,oracle9i,我不可能去装8i,难道就是不支持9i吗,我用这个驱动oracle.jdbc.driver.OracleDriver,不用hibernate也没问题呀,可以用的,可是现在就报这个错。
信息: no JNDI name configured java.lang.UnsupportedOperationException: The user must supply a JDBC connection at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32) at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278) at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264) at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244) at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40) at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19) at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2195) at test.TestName.main(TestName.java:34) 不知道怎么去改,请帮下忙 |
|
返回顶楼 | |