-->
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.  [ 5 posts ] 
Author Message
 Post subject: SchemaExport : Could not read mapping document from file
PostPosted: Wed Aug 30, 2006 1:04 am 
Newbie

Joined: Mon Jun 05, 2006 9:48 am
Posts: 3
Hi All,

I'm trying inheritance OR mapping and following table per class hierarchy. While trying to create ddl using schema export I'm getting this

[schemaexport] Aug 29, 2006 8:27:03 PM org.hibernate.cfg.HbmBinder bindSubclass
[schemaexport] INFO: Mapping subclass: com.look.hub.model.user.PanelistImpl -> users

BUILD FAILED
/home/leema/test/hibernateTools/build.xml:26: Schema text failed: Could not read mapping document from file: /home/leema/test/hibernateTools/src/com/model/user/User.hbm.xml

User.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

      <class name="com.model.user.AgeLifeStage"
      table="life_stage">
      <id name="id"
         type="com.util.hibernate3.StringIdentifierHibernate3Type"
         column="life_stage_id">
         <generator class="assigned" />
      </id>
      <property name="name" type="string"></property>
   </class>

   <class name="com.model.user.Address" table="address">
      <id name="id"
         type="com.util.hibernate3.StringIdentifierHibernate3Type"
         column="address_id">
         <generator class="assigned" />
      </id>      
   </class>

   <class name="com.model.user.Credentials"
      table="credentials">
      <id name="id"
         type="com.util.hibernate3.StringIdentifierHibernate3Type"
         column="credentials_id">
         <generator class="assigned" />
      </id>
      <subclass
         name="com.user.UsernameAndPasswordCredentials" extends="">
         <property name="hashedPassword" type="string"
            column="hashed_password" />         
      </subclass>
   </class>

   <class name="com.model.user.ProfileQuestion"
      table="ProfileQuestions">
      <id name="profileQuestionId"
         type="com.util.hibernate3.StringIdentifierHibernate3Type">
         <generator class="assigned" />
      </id>
      <property name="question" type="string" />
   </class>

   <class name="com.model.user.ProfileQuestionResponse"
      table="ProfileQuestionResponse">
      <id name="id"
         type="com.util.hibernate3.StringIdentifierHibernate3Type">
         <generator class="assigned" />
      </id>
      <many-to-one name="profileQuestion"
         column="profile_question_id" />
      <property name="response" type="string" />      
   </class>
   <class name="com.model.user.User" table="users">
      <id name="id"
         type="com.util.hibernate3.StringIdentifierHibernate3Type"
         column="user_id">
         <generator class="assigned" />
      </id>

      <discriminator type="string" column="type" />
      <subclass name="com.model.user.BaseUser"
         discriminator-value="baseuser" extends="">
         <property name="username" column="user_name" />
         <property name="email" column="email"/>
         <property name="active" column="active"/>
         <many-to-one name="credentials" column="credentials_id"
            unique="true" cascade="all" />
         
         <subclass name="com.model.user.BaseClient"
            discriminator-value="baseclient"
            proxy="com.model.user.Client">
            <property name="name" />
            <subclass
               name="com.model.user.RestrictedPrivClient"
               discriminator-value="restrictedclient">
            </subclass>

            <subclass name="com.model.user.FullPrivClient"
               discriminator-value="fullclient">
            </subclass>
         </subclass>
         <subclass name="com.model.user.AdministratorImpl"
            discriminator-value="admin"
            proxy="com.model.user.Administrator">            
         </subclass>
          <subclass name="com.model.user.PanelistImpl"
            discriminator-value="panelist"
            proxy="com.look.hub.model.user.Panelist">
            
            <property name="firstName" column="first_name" />
            <property name="lastName" column="last_name" />
            <property name="birthdate" column="birth_date" />
            <property name="male" column="male" />

            <many-to-one name="lifeStage" column="life_stage_id" />
          <many-to-one name="address" column="address_id" unique="true"/>   
            <set name="profileQuestionResponses">
            <key column="user_id" />
            <one-to-many class="com.model.user.ProfileQuestionResponse" />
            </set> 
         </subclass> 
      </subclass>
   </class>
</hibernate-mapping>

PanelistImpl.java
Code:
public class PanelistImpl extends BaseUser implements Panelist {

   private boolean male;
   private Address address;
   private AgeLifeStage lifeStage;
   private String firstName = "";
   private String lastName = "";
   private Date birthDate;
   private Set profileQuestionResponses;
   
   public void setProfileQuestionResponses(Set profileQuestionResponses) {
      this.profileQuestionResponses = profileQuestionResponses;
   }
   public Set getProfileQuestionResponses() {
      return profileQuestionResponses;      
   }
   public Date getBirthDate() {
      return birthDate;
   }   
   public void setBirthDate(Date birthDate) {
      this.birthDate = birthDate;
   }
   public boolean getMale() {
      return male;
   }
   public void setMale(boolean male) {
      this.male = male;
   }
   public Address getAddress() {
      return address;
   }
   public void setAddress(Address address) {
      this.address = address;
   }
   
   public AgeLifeStage getLifeStage() {
      return lifeStage;
   }

   public void setLifeStage(AgeLifeStage lifeStage) {
      this.lifeStage = lifeStage;
   }
   public String getFirstName() {
      return firstName;
   }
   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }
   public String getLastName() {
      return lastName;
   }
   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
}


By commenting the subclass elements unser panelist, its running.. What went wrong in my association mapping? As the association to address and AgeLifeStage in unidirectional, i didn't specified anything there..
Can anyone help me out to resolve this?

Thanks in advance
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 2:13 am 
Newbie

Joined: Mon Jun 05, 2006 9:48 am
Posts: 3
Hi..

that problem was with a typo error..

Kindly bare with me


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 9:12 am 
Newbie

Joined: Tue Mar 21, 2006 2:58 am
Posts: 5
sorry, i get the same problem when i'm using the ant task and i can't find my error. the ant task is following:

Code:
   <target name="db-prepare" description="creates database tables">
      <taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
         <classpath>
            <path refid="xdoclet.classpath" />
            <path refid="hibernate.classpath" />
         </classpath>
      </taskdef>

      <generate-database-properties />
      <schemaexport quiet="no" text="text-only" drop="no" delimiter=";" properties="database.properties" output="create-tables.sql">
         <fileset dir="${src.dir}" includes="**/*.hbm.xml" />
      </schemaexport>

      <replaceregexp file="create-tables.sql" match="(.*)foreign key(.*)\;" replace="\1foreign key\2 ON DELETE SET NULL;" flags="g" />

      <sql driver="${database.driver_class}" url="${database.url}" userid="${database.username}" password="${database.password}" classpathref="hibernate.classpath" src="create-tables.sql" />
   </target>


and when i run it it prints out:
Code:
db-prepare:
     [echo] generating database.properties from build.properties
[propertyfile] Updating property file: C:\workspace\sponsoring\database.properties
[schemaexport] (cfg.Environment                     479 ) Hibernate 3.1.3
[schemaexport] (cfg.Environment                     509 ) hibernate.properties not found
[schemaexport] (cfg.Environment                     525 ) using CGLIB reflection optimizer
[schemaexport] (cfg.Environment                     555 ) using JDK 1.4 java.sql.Timestamp handling
[schemaexport] (cfg.Configuration                   240 ) Reading mappings from file: C:\workspace\sponsoring\src\com\bmw\sponsoring\server\
dao\hibernate\KontaktDetail.hbm.xml
[schemaexport] (cfg.HbmBinder                       309 ) Mapping class: com.bmw.sponsoring.server.model.KontaktDetail -> tsponsoring_kontak
t_detail

BUILD FAILED
C:\workspace\sponsoring\build.xml:473: Schema text failed: Could not read mapping document from file: C:\workspace\sponsoring\src\com\bmw\sp
onsoring\server\dao\hibernate\KontaktDetail.hbm.xml


so in the first place it seems that he can find the mapping file, else he wouldn't be able to get the table name out of it. so what could be my error? thanks for any hints.

dominik


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 9:13 am 
Newbie

Joined: Tue Mar 21, 2006 2:58 am
Posts: 5
sorry, i get the same problem when i'm using the ant task and i can't find my error. the ant task is following:

Code:
   <target name="db-prepare" description="creates database tables">
      <taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
         <classpath>
            <path refid="xdoclet.classpath" />
            <path refid="hibernate.classpath" />
         </classpath>
      </taskdef>

      <generate-database-properties />
      <schemaexport quiet="no" text="text-only" drop="no" delimiter=";" properties="database.properties" output="create-tables.sql">
         <fileset dir="${src.dir}" includes="**/*.hbm.xml" />
      </schemaexport>

      <replaceregexp file="create-tables.sql" match="(.*)foreign key(.*)\;" replace="\1foreign key\2 ON DELETE SET NULL;" flags="g" />

      <sql driver="${database.driver_class}" url="${database.url}" userid="${database.username}" password="${database.password}" classpathref="hibernate.classpath" src="create-tables.sql" />
   </target>


and when i run it it prints out:
Code:
db-prepare:
     [echo] generating database.properties from build.properties
[propertyfile] Updating property file: C:\workspace\sponsoring\database.properties
[schemaexport] (cfg.Environment                     479 ) Hibernate 3.1.3
[schemaexport] (cfg.Environment                     509 ) hibernate.properties not found
[schemaexport] (cfg.Environment                     525 ) using CGLIB reflection optimizer
[schemaexport] (cfg.Environment                     555 ) using JDK 1.4 java.sql.Timestamp handling
[schemaexport] (cfg.Configuration                   240 ) Reading mappings from file: C:\workspace\sponsoring\src\com\bmw\sponsoring\server\
dao\hibernate\KontaktDetail.hbm.xml
[schemaexport] (cfg.HbmBinder                       309 ) Mapping class: com.bmw.sponsoring.server.model.KontaktDetail -> tsponsoring_kontak
t_detail

BUILD FAILED
C:\workspace\sponsoring\build.xml:473: Schema text failed: Could not read mapping document from file: C:\workspace\sponsoring\src\com\bmw\sp
onsoring\server\dao\hibernate\KontaktDetail.hbm.xml


so in the first place it seems that he can find the mapping file, else he wouldn't be able to get the table name out of it. so what could be my error? thanks for any hints.

dominik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 2:02 am 
Newbie

Joined: Tue Mar 21, 2006 2:58 am
Posts: 5
i found my problem. i didn't put my classes in the classpath of the task.

so there was just the line

<pathelement location="${classes.dir}" />
missing.

Here's the correct version

Code:
   <target name="db-prepare" description="creates database tables">
      <taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
         <classpath>
            <path refid="xdoclet.classpath" />
            <path refid="hibernate.classpath" />
            <pathelement location="${classes.dir}" />            
         </classpath>
      </taskdef>

      <generate-database-properties />
      <schemaexport quiet="no" text="text-only" drop="no" delimiter=";" properties="database.properties" output="create-tables.sql">
         <fileset dir="${src.dir}" includes="*/**/*.hbm.xml" />
      </schemaexport>

      <replaceregexp file="create-tables.sql" match="(.*)foreign key(.*)\;" replace="\1foreign key\2 ON DELETE SET NULL;" flags="g" />

      <sql driver="${database.driver_class}" url="${database.url}" userid="${database.username}" password="${database.password}" classpathref="hibernate.classpath" src="create-tables.sql" />
   </target>


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