浏览 5695 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2004-03-26
信息: Hibernate 2.1.2 2004-3-26 18:12:42 net.sf.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2004-3-26 18:12:42 net.sf.hibernate.cfg.Environment <clinit> 信息: using CGLIB reflection optimizer 2004-3-26 18:12:42 net.sf.hibernate.cfg.Configuration addClass 信息: Mapping resource: hiberante/PersonModel.hbm.xml 2004-3-26 18:12:43 net.sf.hibernate.cfg.Binder bindRootClass 信息: Mapping class: hiberante.PersonModel -> hib 2004-3-26 18:12:43 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing one-to-many association mappings 2004-3-26 18:12:43 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing one-to-one association property references 2004-3-26 18:12:43 net.sf.hibernate.cfg.Configuration secondPassCompile 信息: processing foreign key constraints 2004-3-26 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 警告: No dialect set - using GenericDialect: The dialect was not set. Set the property hibernate.dialect. 2004-3-26 18:12:44 net.sf.hibernate.dialect.Dialect <init> 信息: Using dialect: net.sf.hibernate.dialect.GenericDialect 2004-3-26 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use outer join fetching: false 2004-3-26 18:12:44 net.sf.hibernate.connection.UserSuppliedConnectionProvider configure 警告: No connection properties specified - the user must supply JDBC connections 2004-3-26 18:12:44 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 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use scrollable result sets: false 2004-3-26 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Use JDBC3 getGeneratedKeys(): false 2004-3-26 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: false 2004-3-26 18:12:44 net.sf.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2004-3-26 18:12:44 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 代码: /* * Created on 2004-3-26 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package hiberante; /** * @author wengsl * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ import net.sf.hibernate.Session; import net.sf.hibernate.Transaction; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.cfg.Configuration; public class TestPersonModel2 { private static SessionFactory sessionFactory; public static void main(String[] args); throws Exception{ Configuration conf= new Configuration();.addClass(PersonModel.class);; //在表中插入第一条数据 sessionFactory = conf.buildSessionFactory();; Session s = sessionFactory.openSession();; Transaction t = s.beginTransaction();; PersonModel p1=new PersonModel();; p1.setName("robin");; p1.setAddress("上海");; //2.持久化 s.save(p1);; //此时p1已经可以在数据库中找到 t.commit();; s.close();; } } 以上代码用的是斑竹的例子 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-03-26
我估计是xml出问题:
<?xml version="1.0" encoding="GB2312"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <class name="hiberante.PersonModel" table="ZY_PERSON"> <!--hibernate为我们生成主键id--> <id name="id" type="long"> <generator class="sequence"> <param name="sequence">ZY_PERSON_ID_SEQ</param> </generator> </id> <property name="name"/> <property name="address"/> </class> </hibernate-mapping> |
|
返回顶楼 |