Hi everyone,
I am using hibernate 2.1 and i m having some problems running SchemaExport. i have a class named AbstractUser which is:
package com.smartprice.eb.valueobject;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
/**
* @author diniz
*
* @hibernate.class table="user"
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public abstract class AbstractUser implements ValueObject {
protected PK primaryKey;
protected String password;
public PrimaryKey getPrimaryKey() {
return getPK();
}
public void setPrimaryKey(PrimaryKey pk) {
this.primaryKey = (PK)pk;
}
public void setPrimaryKey(Serializable pk) {
if (pk instanceof Collection) {
Collection c = (Collection)pk;
Iterator it = c.iterator();
setPrimaryKey(new PK(((Long)it.next()).longValue(), (String)it.next()));
} else {
}
}
/**
* @hibernate.id generator-class="assigned"
*/
private PK getPK(){
return this.primaryKey;
}
/**
* @hibernate.property
*/
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public static class PK implements PrimaryKey {
private long code;
private String login;
public PK() {
this(-1,null);
}
public PK(long code, String login) {
this.code = code;
this.login = login;
}
/**
* @hibernate.property
*/
public long getCode() {
return this.code;
}
/**
* @hibernate.property
*/
public String getLogin(){
return this.login;
}
public boolean equals(Object o){
AbstractUser.PK pk = (AbstractUser.PK) o;
if (this.code == pk.getCode() && this.login.equals(pk.getLogin())){
return true;
}
else{
return false;
}
}
}
}
After running hibernatedoclet task it s mapped to:
<hibernate-mapping>
<class
name="com.smartprice.eb.valueobject.AbstractUser"
table="user"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="PK"
class="com.smartprice.eb.valueobject.AbstractUser.PK"
>
<key-property
name="code"
type="long"
column="code"
/>
<key-property
name="login"
type="java.lang.String"
column="login"
/>
</composite-id>
<property
name="password"
type="java.lang.String"
update="true"
insert="true"
column="password"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-AbstractUser.xml
containing the additional properties and place it in your merge dir.
-->
<joined-subclass
name="com.smartprice.eb.valueobject.Admin"
dynamic-update="false"
dynamic-insert="false"
>
<key
column=""
/>
</joined-subclass>
<joined-subclass
name="com.smartprice.eb.valueobject.Buyer"
dynamic-update="false"
dynamic-insert="false"
>
<key
column=""
/>
</joined-subclass>
<joined-subclass
name="com.smartprice.eb.valueobject.Seller"
dynamic-update="false"
dynamic-insert="false"
>
<key
column=""
/>
</joined-subclass>
</class>
</hibernate-mapping>
When i run the schemaexport task it gives the following:
[schemaexport] Jun 24, 2004 3:27:49 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: Hibernate 2.1 rc1
[schemaexport] Jun 24, 2004 3:27:49 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=gap, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect, hibernate.connection.url=jdbc:postgresql://michelangelo.smartprice.com.br:5432/gap, hibernate.connection.driver_class=org.postgresql.Driver}
[schemaexport] Jun 24, 2004 3:27:50 PM net.sf.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: using CGLIB reflection optimizer
[schemaexport] Jun 24, 2004 3:27:51 PM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] INFO: Mapping file: /home/leorazuk/work/freecommerce/ebusiness/build/xdoclet/gen-src/com/smartprice/eb/valueobject/AbstractUser.hbm.xml
[schemaexport] Jun 24, 2004 3:27:53 PM net.sf.hibernate.cfg.Binder bindRootClass
[schemaexport] INFO: Mapping class: com.smartprice.eb.valueobject.AbstractUser -> user
[schemaexport] Jun 24, 2004 3:27:54 PM net.sf.hibernate.cfg.Configuration add
[schemaexport] SEVERE: Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: component class not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:712)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:263)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1173)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:185)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:131)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:301)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:632)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:183)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
[schemaexport] Caused by: java.lang.ClassNotFoundException: com.smartprice.eb.valueobject.AbstractUser.PK
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1150)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1091)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:961)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:140)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:75)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:709)
[schemaexport] ... 16 more
[schemaexport] Jun 24, 2004 3:27:54 PM net.sf.hibernate.cfg.Configuration addFile
[schemaexport] SEVERE: Could not configure datastore from file: /home/leorazuk/work/freecommerce/ebusiness/build/xdoclet/gen-src/com/smartprice/eb/valueobject/AbstractUser.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: component class not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:712)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:263)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1173)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:167)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:185)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:131)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:301)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:632)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:183)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
[schemaexport] Caused by: java.lang.ClassNotFoundException: com.smartprice.eb.valueobject.AbstractUser.PK
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1150)
[schemaexport] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1091)
[schemaexport] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:961)
[schemaexport] at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
[schemaexport] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
[schemaexport] at java.lang.Class.forName0(Native Method)
[schemaexport] at java.lang.Class.forName(Class.java:140)
[schemaexport] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:75)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:709)
[schemaexport] ... 16 more
BUILD FAILED
Does anyone know why it doesn't find the AbstractUser.PK class?
Regards,
Leonardo
|