-->
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.  [ 1 post ] 
Author Message
 Post subject: Embedded Error with composite-id
PostPosted: Tue May 05, 2009 4:05 am 
Newbie

Joined: Tue May 05, 2009 3:11 am
Posts: 3
Hi,

I have a problem with the creation of composite primary keys with forgein keys. An exception is thrown when executing an ant-taks with maven and hbm2ddl. It mentions that the class of the composite id is not found, but I thought this class will be created by excuting hbm2ddl or hbm2java.

Maybe someone here got the same error and probably can help me.

Thanks in Advance!

The mapping file:

Code:
?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 package="testpackage" default-access="field">
  <class name="testpackage.testclass" table="TESTTABLE_T" mutable="false">

    <composite-id name="id" class="testclass$Id">
        <key-property name="roleId" access="field" column="ROLE_ID"/>
        <key-property name="permissionId" access="field" column="PERMISSION_ID"/>
    </composite-id>
   
    <property name="created"  column="CREATED"  type="timestamp" not-null="true"/>
   
     <many-to-one   name="role"
                    column="ROLE_ID"
                    not-null="true"
                    insert="false"
                    update="false"
                    foreign-key="FK_RTP_TO_ROLE"/>

    <many-to-one   name="permission"
                    column="PERMISSION_ID"
                    not-null="true"
                    insert="false"
                    update="false"
          foreign-key="FK_RTP_TO_PERMISSION"/>
    </class>
</hibernate-mapping>


Exception (ant-task with maven):

Code:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from resource testpackage/testclass.hbm.xml
[hibernatetool] org.hibernate.MappingException: class testpackage.testclass$Id not found while looking for property: roleId
[hibernatetool] java.lang.ClassNotFoundException: testpackage.testclass$Id
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks

Embedded error: org.hibernate.InvalidMappingException: Could not parse mapping document from resource testpackage/testclass.hbm.xml
testpackage.testclass$Id
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:703)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing ant tasks
        at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:114)
        at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
        ... 16 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource testpackage/testclass.hbm.xml
        at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
        ... 19 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource testpackage/testclass.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:575)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1468)
        at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:96)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
        at org.hibernate.tool.ant.Hbm2DDLExporterTask.createExporter(Hbm2DDLExporterTask.java:51)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
        ... 23 more
Caused by: org.hibernate.MappingException: class testpackage.testclass$Id not found while looking for property: roleId
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
        at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:279)
        at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2171)
        at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1900)
        at org.hibernate.cfg.HbmBinder.bindCompositeId(HbmBinder.java:1723)
        at org.hibernate.cfg.HbmBinder.bindCompositeId(HbmBinder.java:424)
        at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:338)
        at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
        at org.hibernate.cfg.Configuration.add(Configuration.java:675)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:510)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:572)
        ... 34 more
Caused by: java.lang.ClassNotFoundException: testpackage.testclass$Id
        at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1166)
        at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
        at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:70)
        ... 45 more


greets
andy


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

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.