Hi,
I'm using hbm2ddl programmatically in a customized eclipse plugin. This works great for simple mappings. As soon as composite id's are involved in the mappings, hbm2ddl uses cglib which tries to call the POJO itself. This results in a MappingException (Component Class not found) and originally in a ClassNotFoundException.
Obviously it would be a solution to add the POJO class to the plugin classpath. But this is not that easy since multiple projects would be necessary in the classpath.
Anyway, I wonder why hbm2ddl needs the POJO classes since it seems as if all information needed to generate the ddl script is available in the mapping file.
Is there a way to configure hbm2ddl not to use the POJO classes?
Thanks in advance!
Thomas
Hibernate version: 3.1.3
Example-Mapping:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="ch.edoras.standard.dms.filestore.model.FileMetaData" table="DMS_FILE_META_DATA" lazy="false">
<composite-id>
<key-property name="id" column="ID" type="long"/>
<key-property name="versionNumber" column="version_number" type="int"/>
</composite-id>
<property name="createdAt" column="CREATED_AT" type="timestamp" length="20" />
<property name="creationUser" column="CREATION_USER" type="string" length="20" />
<property name="lastVersionIdentifier" column="LAST_VERSION_IDENTIFIER" type="boolean" length="20" not-null="true" />
<property name="modifiedAt" column="MODIFIED_AT" type="timestamp" length="20" />
<property name="modificationUser" column="MODIFICATION_USER" type="string" length="20" />
<property name="fileExtension" column="FILE_EXTENSION" type="string" length="20" />
<property name="fileId" column="FILE_ID" type="string" length="20" />
<property name="fileName" column="FILE_NAME" type="string" length="20" />
<property name="fileSize" column="FILE_SIZE" type="long" length="20" />
<property name="fileComments" column="FILE_COMMENTS" type="string" length="20" />
<property name="documentInfo" column="DOCUMENT_INFO" type="string" length="20" />
<property name="keywords" column="KEYWORDS" type="string" length="20" />
<property name="category" column="CATEGORY" type="string" length="20" />
<property name="compressedFileInfo" column="COMPRESSED_FILE_INFO" type="string" />
</class>
</hibernate-mapping>
Stack-Trace:
Code:
Caused by: org.hibernate.MappingException: component class not found: ch.edoras.standard.dms.filestore.model.FileMetaData
at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:155)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:40)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:43)
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:91)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:59)
at edoras.tools.edsmm.sql.SqlGenerator.generate(SqlGenerator.java:109)
at edoras.tools.edsmm.actions.GenerateSqlAction.doGenerate(GenerateSqlAction.java:156)
at edoras.tools.edsmm.actions.GenerateSqlAction.access$0(GenerateSqlAction.java:153)
at edoras.tools.edsmm.actions.GenerateSqlAction$SqlWorkspaceModifyOperation.execute(GenerateSqlAction.java:233)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:98)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1721)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:110)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Caused by: java.lang.ClassNotFoundException: ch.edoras.standard.dms.filestore.model.FileMetaData
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:350)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:78)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
... 18 more
Root exception:
org.hibernate.MappingException: component class not found: ch.edoras.standard.dms.filestore.model.FileMetaData
at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:155)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:40)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:43)
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:91)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:59)
at edoras.tools.edsmm.sql.SqlGenerator.generate(SqlGenerator.java:109)
at edoras.tools.edsmm.actions.GenerateSqlAction.doGenerate(GenerateSqlAction.java:156)
at edoras.tools.edsmm.actions.GenerateSqlAction.access$0(GenerateSqlAction.java:153)
at edoras.tools.edsmm.actions.GenerateSqlAction$SqlWorkspaceModifyOperation.execute(GenerateSqlAction.java:233)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:98)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1721)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:110)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Caused by: java.lang.ClassNotFoundException: ch.edoras.standard.dms.filestore.model.FileMetaData
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:350)
at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:78)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
... 18 more