Hi,
I'm new to Hibernate. ;)
I have a JBoss running and a HypersonicDB as Server Engine running.
I set up a small phonebook-Table, which was is accessable through Hibernate Tools.
So I finished everything as it mentioned in the tutorial...
Now I generated a DAO-File to test the generated files...
This is my CFG:
Code:
<?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>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://dbserver:1701</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<mapping resource="de/siller/test/PhonebookHibernate.hbm.xml" />
</session-factory>
</hibernate-configuration>
Code:
<?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="de.siller.test.PhonebookHibernate" table="PHONEBOOK_HIBERNATE" schema="PUBLIC">
<id name="userid" type="string">
<column name="USERID" length="10" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="NAME" length="30" />
</property>
<property name="number" type="string">
<column name="NUMBER" length="20" />
</property>
</class>
</hibernate-mapping>
In my testAPP i have the following code.. which may be wrong, cause it is to easy... ;)
Code:
PhonebookHibernateHome phh = new PhonebookHibernateHome();
PhonebookHibernate ph = new PhonebookHibernate();
ph.setName("Test");
ph.setNumber("2193042");
ph.setUserid("esgf");
phh.persist(ph);
Then I get the following Exception...
Code:
Could not locate SessionFactory in 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(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source).....
What's wrong?
Hope you can help me.
Greetings,
James