-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to map class A extends B
PostPosted: Thu Dec 02, 2004 5:50 pm 
Newbie

Joined: Thu Dec 02, 2004 2:13 pm
Posts: 10
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:


Top
 Profile  
 
 Post subject: Re: How to map class A extends B
PostPosted: Thu Dec 02, 2004 5:54 pm 
Newbie

Joined: Thu Dec 02, 2004 2:13 pm
Posts: 10
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.