-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems generating DDL file for an entity with composite-id
PostPosted: Thu Jun 24, 2004 2:43 pm 
Newbie

Joined: Thu Jun 24, 2004 1:49 pm
Posts: 4
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 9:17 am 
Newbie

Joined: Thu Jun 24, 2004 1:49 pm
Posts: 4
I forgot to say that the classpath is set to:

<path id="lib.class.path">
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="/home/leorazuk/work/fapemig/lib/xdoclet">
<include name="*.jar"/>
</fileset>
<fileset dir="${build.dir}">
<include name="*.jar"/>
</fileset>
</path>

and the jar in ${build.dir} has all the classes inside it. If i try to generate the schema for classes with no composite-id, it works fine.


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