Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.8
Mapping documents:
This one is related to Concursos class
Concursos.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="org.hibernate.entregar">
<class name="Concursos" table="concurso">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="descripcion" column="descripcion" type="string"/>
<property name="acronimo" column="acronimo" type="string"/>
<bag name="restricciones" lazy="true" inverse="true" >
<key column="id"/>
<one-to-many class="Restricciones"/>
</bag>
</class>
</hibernate-mapping>
This one is related to class Restricciones
Restricciones.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="org.hibernate.entregar">
<class name="Restricciones" table="opciones">
<id name="id" column="id">
<generator class="native"/>
</id>
<many-to-one name="concurso" column="concurso_ID" not-null="true" />
<property name="opcion" column="opcion" not-null="true" type="string"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[java] 15:34:42,615 INFO Environment:542 - using java.io streams to persis
t binary types
[java] 15:34:42,615 INFO Environment:543 - using CGLIB reflection optimize
r
[java] 15:34:42,615 INFO Environment:572 - using JDK 1.4 java.sql.Timestam
p handling
[java] 15:34:42,625 INFO Configuration:351 - Mapping resource: org/hibernate/entregar/Concursos.hbm.xml
[java] 15:34:43,346 INFO Binder:229 - Mapping class: org.hibernate.entregar.Concursos -> concurso
[java] 15:34:43,486 INFO Configuration:351 - Mapping resource: org/hibernate/entregar/Restricciones.hbm.xml
[java] 15:34:43,526 INFO Binder:229 - Mapping class: org.hibernate.entregar.Restricciones -> opciones
[java] 15:34:43,536 INFO Configuration:641 - processing one-to-many association mappings
[java] 15:34:43,546 INFO Binder:1181 - Mapping collection: org.hibernate.entregar.Concursos.restricciones -> opciones
[java] 15:34:43,546 INFO Configuration:650 - processing one-to-one association property references
[java] 15:34:43,546 INFO Configuration:675 - processing foreign key constraints
[java] 15:34:43,596 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
[java] 15:34:43,606 INFO SettingsFactory:70 - Maximim outer join fetch depth: 1
[java] 15:34:43,606 INFO SettingsFactory:74 - Use outer join fetching: true
[java] 15:34:43,616 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
[java] 15:34:43,616 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 1
[java] 15:34:43,636 INFO DriverManagerConnectionProvider:77 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql:///prueba
[java] 15:34:43,636 INFO DriverManagerConnectionProvider:78 - connection properties: {user=shevek, password=anarres}
[java] 15:34:43,646 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[java] 15:34:44,357 INFO SettingsFactory:114 - Use scrollable result sets: true
[java] 15:34:44,357 INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
[java] 15:34:44,357 INFO SettingsFactory:120 - Optimize cache for minimal puts: false
[java] 15:34:44,357 INFO SettingsFactory:129 - Query language substitution s: {no='N', true=1, yes='Y', false=0}
[java] 15:34:44,367 INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
[java] 15:34:44,377 INFO SettingsFactory:152 - query cache factory: net.sf.hibernate.cache.StandardQueryCacheFactory
[java] 15:34:44,377 INFO Configuration:1130 - instantiating and configuring caches
[java] 15:34:44,657 INFO SessionFactoryImpl:119 - building session factory
[java] java.lang.NullPointerException
[java] at org.hibernate.entregar.gui.VentanaServidorConcursos.<init>(Ve
ntanaServidorConcursos.java:44)
[java] at org.hibernate.entregar.gui.VentanaServidorConcursos.main(Vent
anaServidorConcursos.java:381)
Name and version of the database you are using: MySQL 4.0.15
The generated SQL (show_sql=true): It does not generate SQL
Debug level Hibernate log excerpt:
Hello:
Iam trying to run an small example. There are two classes mapped with two different tables. In the first one (Concursos), there is a property that is a list of objects from the other class. That is mapped in this way:
<bag name="restricciones" lazy="true" inverse="true" >
<key column="id"/>
<one-to-many class="Restricciones"/>
</bag>
In the other class (Restricciones), there's a property that is an object from the other class. The mapping is this:
<many-to-one name="concurso" column="concurso_ID" not-null="true" />
As you can see in the trace, when hibernate is building the sessionFactory it crashes with a "nullPointerException"