| Hibernate version  :2.1 
 Mapping documents:<?xml version="1.0" encoding="GB2312"?>
 <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
 <hibernate-mapping>
 <class name="firsthibernate.PersonModel"
 table="ZY_PERSON">
 
 <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>
 
 
 Code between sessionFactory.openSession() and session.close():
 package firsthibernate;
 
 import net.sf.hibernate.Session;
 import net.sf.hibernate.SessionFactory;
 import net.sf.hibernate.cfg.Configuration;
 import net.sf.hibernate.Query;
 
 public class TestPersonModel3 {
 //private static SessionFactory sessionFactory;
 public static void main(String[] args) throws Exception{
 //Configuration conf= new Configuration().addClass(PersonModel.class);
 SessionFactory sf = new Configuration().configure().buildSessionFactory();
 //sessionFactory = conf.buildSessionFactory();
 Session s = sf.openSession();
 PersonModel p = new PersonModel();
 Query q = s.createQuery("from PersonModel as p where p.id=1");
 
 p = (PersonModel) q.list().get(0);
 System.out.println(p.getName());
 s.close();
 }
 }
 
 
 Full stack trace of any exception that occurs:
 
 Name and version of the database you are using:
 oracle 9i
 
 Debug level Hibernate log excerpt:
 
 I am a beginner.In my program,I do not use any jndi,and I do not config anything about jndi,but the exception occored.Although it doesn't cause the wrong results,but how can I reslove the problem?
 By the way,in the hibernate.cfg.xml and *.hbm.xml,I do not set anything about jndi.
 
 thanks for help!
 
 
 
 
 00:22:18,593  INFO SessionFactoryObjectFactory:86 - Factory name: java:comp/env/hibernate/SessionFactory
 
 00:22:18,593  INFO NamingHelper:26 - JNDI InitialContext properties:{}
 
 00:22:18,609  WARN SessionFactoryObjectFactory:98 - Could not bind factory to JNDI
 
 javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
 
 at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
 
 at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
 
 at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
 
 at javax.naming.InitialContext.getNameParser(InitialContext.java:429)
 
 at net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
 
 at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
 
 at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:172)
 
 at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)
 
 at firsthibernate.TestPersonModel3.main(TestPersonModel3.java:12)
 
 00:22:18,656  INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
 
 00:22:18,718  INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache
 
 robin//this is result.
 
 
 |