Hi,
Does hbm2java supports composite-id?! We are using HibernateTools-3.1.0.beta4.
Code:
<hibernate-mapping package="com.mycompany.dal.entity">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<meta attribute="extends">com.mycompany.dal.entity.StandardEntity</meta>
<class name="Role" table="user_roles">
<composite-id name="id" class="Role$Id"> <!-- or RolePK none work! -->
<key-property name="userName" type="string" column="user_name" length="15"/>
<key-property name="roleName" type="string" column="role_name" length="15"/>
</composite-id>
</class>
</hibernate-mapping>
generates:
Code:
org.hibernate.MappingException: component class not found: com.mycompany.dal.entity.Role$Id
at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:140)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:79)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:33)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:126)
at org.hibernate.mapping.Component.getType(Component.java:160)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
at org.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:601)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:712)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:96)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:64)
at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:43)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:143)
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.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
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:585)
at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:16)
Caused by: java.lang.ClassNotFoundException: com.mycompany.dal.entity.Role$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:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
... 29 more
If we generate RolePk every think will go fine.
Any Idea?!
Regards,
Alireza Fattahi