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.  [ 5 posts ] 
Author Message
 Post subject: entity unknown although it is existent
PostPosted: Sun Sep 18, 2005 10:23 am 
Newbie

Joined: Sun Sep 18, 2005 9:05 am
Posts: 4
i'm using andromda (andromda-bin-3.1-RC1-SNAPSHOT) to generate my java-classes and hibernate mapping files. from those generated files i've generated my DB-tables using hbm2DDL.
now i'm trying to save a transient object graph and become the following exception:


Hibernate version: 3.0.5

Full stack trace of any exception that occurs:
org.hibernate.MappingException: Unknown entity: business.model.FormVersionImpl
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at test.FormVersionTest.testCascadedCreateFormVersion(FormVersionTest.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


Name and version of the database you are using: DB2 v8




The class 'business.model.FormVersionImpl' has also been generated with the abstract class 'business.model.FormVersion'. they are all in the same package. why is hibernate missing it?

thanx for any help!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 10:36 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
I would say that something is wrong in your mapping.

Could you post your mapping (complete mapping of FormVersionImpln class) and the test code (at least test.FormVersionTest.testCascadedCreateFormVersion)?

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 11:10 am 
Newbie

Joined: Sun Sep 18, 2005 9:05 am
Posts: 4
hi erik,

thanx for your interest. here the mapping file:
Code:
<hibernate-mapping default-cascade="none">
    <class name="business.model.FormVersionImpl" table="FOXF02" dynamic-insert="false" dynamic-update="false">
        <id name="formVersionId" type="long" unsaved-value="0">
            <column name="ID_FODE" sql-type="BIGINT"/>
            <generator class="increment">
            </generator>
        </id>
        <property name="revision" type="long">
            <column name="REVISION" not-null="true" unique="false" sql-type="BIGINT"/>
        </property>
        <property name="width" type="int">
            <column name="FORMWIDTH" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="CA_STATUS" type="int">
            <column name="CA_STATUS" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="status" type="short">
            <column name="CO_STATUS" not-null="true" unique="false" sql-type="SMALLINT"/>
        </property>
        <property name="lockuser" type="java.lang.String">
            <column name="LOCKUSER" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="startDate" type="java.util.Date">
            <column name="STARTDATE" not-null="true" unique="false" sql-type="DATE"/>
        </property>
        <property name="endDate" type="java.util.Date">
            <column name="ENDDATE" not-null="true" unique="false" sql-type="DATE"/>
        </property>
        <property name="formId" type="long">
            <column name="ID_FOTY" not-null="true" unique="false" sql-type="BIGINT"/>
        </property>
        <property name="spare" type="int">
            <column name="SPARE" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="textFont" type="java.lang.String">
            <column name="TXTFONT" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="refFont" type="java.lang.String">
            <column name="REFFONT" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="splitTop" type="int">
            <column name="SPLITTOP" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="splitLeft" type="int">
            <column name="SPLITLEFT" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="labelReferenceKey" type="long">
            <column name="ID_POREKE" not-null="true" unique="false" sql-type="BIGINT"/>
        </property>
        <property name="sortNumber" type="int">
            <column name="SORTNUMBER" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="organizationUnit" type="java.lang.String">
            <column name="ORGUNIT" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="numberOfFreezedBlocksAtTop" type="int">
            <column name="XFRZBLKTOP" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="numberOfFreezedRowsInLastBlockTop" type="int">
            <column name="XFRZCCTOP" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="numberOfFreezedColumnsAtLeft" type="int">
            <column name="XFRZCCLEFT" not-null="true" unique="false" sql-type="INTEGER"/>
        </property>
        <property name="createDate" type="java.sql.Timestamp">
            <column name="CREATEDATE" not-null="true" unique="false" sql-type="TIMESTAMP"/>
        </property>
        <property name="createUser" type="java.lang.String">
            <column name="CREATEUSER" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="updateDate" type="java.util.Date">
            <column name="updateDate" not-null="true" unique="false" sql-type="DATE"/>
        </property>
        <property name="CUser" type="java.lang.String">
            <column name="CUSER" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="CDate" type="java.sql.Timestamp">
            <column name="CDATE" not-null="true" unique="false" sql-type="TIMESTAMP"/>
        </property>
        <property name="UUser" type="java.lang.String">
            <column name="UUSER" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <property name="UDate" type="java.sql.Timestamp">
            <column name="UDATE" not-null="true" unique="false" sql-type="TIMESTAMP"/>
        </property>
        <property name="updateUser" type="java.lang.String">
            <column name="UPDATEUSER" not-null="true" unique="false" sql-type="VARCHAR(256)"/>
        </property>
        <set name="blockList" order-by="ID_FODE" lazy="true" fetch="select" inverse="true">
            <key foreign-key="FOXF03_ID_FODEC">
                <column name="ID_FODE" sql-type="BIGINT"/>
            </key>
            <one-to-many class="business.model.BlockImpl"/>
        </set>
    </class>
</hibernate-mapping> 



... and the test code...

Code:
public void testCascadedCreateFormVersion()
   {
      FormVersion fullFormVersion = (FormVersion)getFullFormVersion();
      HibernateUtil.beginnTransaction();
      
      Session session = HibernateUtil.getSession();
      session.save(fullFormVersion);
      
      HibernateUtil.commitTransaction();
        HibernateUtil.closeSession();
   }



the method 'getFullFormVersion' returns a new created instance of 'FormVersionImpl'


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 12:17 pm 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Hi,

The problem is not the mapping file, but probably hibernate.cfg.xml: I can reproduce your error if I "forget" to declare the mapping of FormVersionImpl in the Hibernate config file.

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 12:40 pm 
Newbie

Joined: Sun Sep 18, 2005 9:05 am
Posts: 4
great!!
that's the problem. i did comment out the mappings from config (don't ask me wy, i don't remember. i was trying something...) and didn't notice it.

thanxs a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.