HELLO: Please, I need to know why this don't work in
Hibernate version: Hibernate 3.1.3
Mapping documents:
This is Persona.hbm.xml
<?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="encuestas.Persona"
table="PERSONA"
lazy="true"
abstract="true">
<id name="id"
type="long"
column="PERSONA_ID">
<generator class="native"/>
</id>
<property name="rut"
type="long"
not-null="true">
<column name="RUT"/>
</property>
<property name="telefono"
type="long"
not-null="true">
<column name="TELEFONO"/>
</property>
<joined-subclass name="Alumno" table="ALUMNO">
<key column="ALUMNO_ID"/>
<property name="Agno_ingreso"
type="int"
not-null="true"
update="false">
<column name="AGNO_INGRESO"/>
</property>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Full stack trace of any exception that occurs:
run:
[java] 20:09:26,805 INFO Environment:479 - Hibernate 3.1.3
[java] 20:09:26,822 INFO Environment:509 - hibernate.properties not found
[java] 20:09:26,829 INFO Environment:525 - using CGLIB reflection optimizer
[java] 20:09:26,833 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
[java] 20:09:26,970 INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
[java] 20:09:26,970 INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
[java] 20:09:27,664 INFO Configuration:469 - Reading mappings from resource: encuestas/Persona.hbm.xml
[java] 20:09:27,950 INFO HbmBinder:309 - Mapping class: encuestas.Persona -> PERSONA
[java] 20:09:28,054 INFO HbmBinder:883 - Mapping joined-subclass: Alumno -> ALUMNO
[java] 20:09:28,071 INFO Configuration:469 - Reading mappings from resource: encuestas/FormaRpta.hbm.xml
[java] 20:09:28,165 INFO HbmBinder:309 - Mapping class: encuestas.FormaRpta -> FORMA_RPTA
[java] 20:09:28,327 INFO Configuration:469 - Reading mappings from resource: encuestas/Forma.hbm.xml
[java] 20:09:28,394 INFO HbmBinder:309 - Mapping class: encuestas.Forma -> FORMA
[java] 20:09:28,401 INFO Configuration:469 - Reading mappings from resource: encuestas/Detalle.hbm.xml
[java] 20:09:28,445 INFO HbmBinder:309 - Mapping class: encuestas.Detalle -> DETALLE
[java] 20:09:28,451 INFO HbmBinder:1397 - Mapping collection: encuestas.Detalle.rptas_posibles -> RPTAS_POSIBLES
[java] 20:09:28,452 INFO Configuration:1419 - Configured SessionFactory: null
[java] 20:09:28,454 INFO HbmBinder:2349 - Mapping collection: encuestas.Forma.detalles -> DETALLE
[java] 20:09:28,845 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[java] 20:09:28,850 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[java] 20:09:28,850 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[java] 20:09:28,858 INFO DriverManagerConnectionProvider:80 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/encuesta01
[java] 20:09:28,859 INFO DriverManagerConnectionProvider:86 - connection properties: {user=root, password=****}
[java] 20:09:29,449 INFO SettingsFactory:77 - RDBMS: MySQL, version: 5.0.22-Debian_0ubuntu6.06.2-log
[java] 20:09:29,449 INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.13 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
[java] 20:09:29,482 INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLDialect
[java] 20:09:29,497 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
[java] 20:09:29,502 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[java] 20:09:29,503 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
[java] 20:09:29,503 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
[java] 20:09:29,503 INFO SettingsFactory:136 - JDBC batch size: 15
[java] 20:09:29,504 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
[java] 20:09:29,505 INFO SettingsFactory:144 - Scrollable result sets: enabled
[java] 20:09:29,506 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
[java] 20:09:29,506 INFO SettingsFactory:160 - Connection release mode: auto
[java] 20:09:29,508 INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
[java] 20:09:29,509 INFO SettingsFactory:187 - Default batch fetch size: 1
[java] 20:09:29,510 INFO SettingsFactory:191 - Generate SQL with comments: disabled
[java] 20:09:29,514 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
[java] 20:09:29,515 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[java] 20:09:29,522 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
[java] 20:09:29,523 INFO SettingsFactory:203 - Query language substitutions: {}
[java] 20:09:29,523 INFO SettingsFactory:209 - Second-level cache: enabled
[java] 20:09:29,523 INFO SettingsFactory:213 - Query cache: disabled
[java] 20:09:29,524 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
[java] 20:09:29,534 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
[java] 20:09:29,534 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
[java] 20:09:29,550 INFO SettingsFactory:257 - Echoing all SQL to stdout
[java] 20:09:29,551 INFO SettingsFactory:264 - Statistics: disabled
[java] 20:09:29,551 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
[java] 20:09:29,551 INFO SettingsFactory:283 - Default entity-mode: pojo
[java] 20:09:29,642 INFO SessionFactoryImpl:154 - building session factory
[java] Initial SessionFactory creation failed.org.hibernate.MappingException: proxy class not found: Alumno
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at encuestas.EncuestaManager.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: proxy class not found: Alumno
[java] at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:109)
[java] at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:116)
[java] at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
[java] at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
[java] at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
[java] at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
[java] at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:90)
[java] at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
[java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
[java] ... 2 more
[java] Caused by: java.lang.ClassNotFoundException: Alumno
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:272)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:140)
[java] at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
[java] at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:106)
[java] ... 12 more
[java] Java Result: 1
Name and version of the database you are using:
Mysql 5.0.22-Debian_0ubuntu6.06.2
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
when I mapping a subclass, It's not work. I don't know why, what is wrong in session factory? I followed reference manual to learn about subclass mapping, but I have this problem. The root class is 'Persona' and the subclass is 'Alumno'. Please, help me!!!
|