Ok. so I got this working a minute after posting. The default constructor has to be public. Why is this the case?
c.
chuisman9955 wrote:
Hello I am trying to map a classs that extends another class. Nothing fancy, Class A extends Class B. When I try to run my test program I get the stated excpetion. Do I have to indicate in the mapping that my class B extends class A? If so how do I go about doing this?
Thank you,
Chris.
Hibernate version: 2.1.7c
Mapping documents:
<hibernate-mapping package="com.taylor.qseries.server.model.metadata">
<class name="EERouting" table="ROUTINGS" lazy="true">
<!-- Common id property. -->
<id name="id_" type= "long" column="ID" access="field">
<generator class="native"/>
</id>
<!-- Name is limited to 255 characters.-->
<property name="displayName_" type="string" access="field">
<column name="NAME" not-null="true" length="80"
unique-key="UNIQUE_NAME_AT_LEVEL"/>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
EERouting routing = new EERouting("Test Routing");
session.save(routing);
transaction.commit();
session.close();
Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: CGLIB Enhancement failed
at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:84)
at net.sf.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:36)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:818)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:692)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:796)
at com.taylor.qseries.server.model.metadata.HibernateRoutingTest.main(HibernateRoutingTest.java:42)
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:783)
at net.sf.cglib.proxy.Enhancer.emit(Enhancer.java:749)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:481)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:368)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:280)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:597)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:74)
... 7 more
Name and version of the database you are using:
Oracle 9.2.0.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: