Hibernate tutorial: One to one and Many to many mapping annotation

This post about hibernate tutorial i will show how to implement many to many and one to one mapping in hibernate using JPA annotation. We will using source code from previous post Hibernate tutorial: one-to-many mapping annotation as code base for this article.
Continue reading Hibernate tutorial: One to one and Many to many mapping annotation

Hibernate – WARN: HHH000374: Could not unbind factory from JNDI


When run application with hibernate outside JEE environment we get follow warning

WARN: HHH000277: Could not bind factory to JNDI
org.hibernate.engine.jndi.JndiException: Error parsing JNDI name []
	at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:141)
	at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:157)
	at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:103)
	at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:497)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
Caused by: 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:662)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
	at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
	at javax.naming.InitialContext.getNameParser(InitialContext.java:499)
	at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:135)
	... 7 more


The above issue occur cause you specific name on your hibernate configuration file

<session-factory name="">


When run hibernate application outside JEE environment, you should remove name property from hibernate configuration file as below

<session-factory >