-->
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.  [ 7 posts ] 
Author Message
 Post subject: Mappingexception
PostPosted: Sat Nov 27, 2004 5:08 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

I'm getting a maping exception trying to generate a database schema.
I'm a newbie type user, so I'm probably doing something stupid. In this case I'm trying to create a single database table that contains two subclasses: user and subscriber. I'm getting this error.

Any help's appreciated.

Marc

BUILD FAILED: D:\Java\Projects\dates4free\build-mschipperheyn.xml:226: Schema text failed: net.sf.hibernate.MappingException: Could not interpret type: String

Mapping documents:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="nl.msw.dates4free.business.entities.aUser"
        table="Users"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="userID"
            column="UserID"
            type="long"
            unsaved-value="0"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-aUser.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="Subclass"
        />

        <property
            name="email"
            type="String"
            update="true"
            insert="true"
            access="property"
            column="getEmail"
            not-null="false"
            unique="false"
        />

        <property
            name="firstName"
            type="String"
            update="true"
            insert="true"
            access="property"
            column="getFirstName"
            not-null="false"
            unique="false"
        />

        <property
            name="lastName"
            type="String"
            update="true"
            insert="true"
            access="property"
            column="getLastName"
            not-null="false"
            unique="false"
        />

        <property
            name="userName"
            type="String"
            update="true"
            insert="true"
            access="property"
            column="getUserName"
            not-null="false"
            unique="false"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-aUser.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="nl.msw.dates4free.business.entities.User"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="USER"
        >

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-User.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="nl.msw.dates4free.business.entities.Subscriber"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="SUBSCRIBER"
        >

        <one-to-one
            name="tokenAccount"
            class="nl.msw.dates4free.business.entities.TokenAccount"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <property
            name="dateAdded"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="dateAdded"
        />

        <property
            name="mobile"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="mobile"
        />

        <property
            name="online"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="online"
        />

        <property
            name="hits"
            type="long"
            update="true"
            insert="true"
            access="property"
            column="hits"
            not-null="false"
            unique="false"
        />

        <property
            name="popularity"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="popularity"
            not-null="false"
            unique="false"
        />

        <set
            name="bookmarks"
            table="Bookmarks"
            lazy="true"
            inverse="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BookmarkUserID"
                  outer-join="auto"
               />

        </set>

        <set
            name="messages"
            lazy="true"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
            order-by="DateSent desc"
        >

              <key
                  column="To"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Message"
              />

        </set>

        <set
            name="blockedUsers"
            table="BlockedUsers"
            lazy="true"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BlockedSubscriberID"
                  outer-join="auto"
               />

        </set>

        <set
            name="favouriteUsers"
            table="FavouriteUsers"
            lazy="true"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="FavouriteSubscriberID"
                  outer-join="auto"
               />

        </set>

        <one-to-one
            name="photo"
            class="nl.msw.dates4free.business.entities.Photo"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <set
            name="photos"
            lazy="false"
            inverse="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="UserID"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Photo"
              />

        </set>

        <property
            name="receiveSMS"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="receiveSMS"
        />

        <property
            name="votes"
            type="long"
            update="true"
            insert="true"
            access="property"
            column="votes"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-Subscriber.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 27, 2004 5:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate mappings are case sensitive.

Your "String" type should probably be "string" or "java.lang.String" dependent on your style (shorthand vs. explicit ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Replies lost
PostPosted: Mon Nov 29, 2004 10:31 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

my replies seem to have disappeared. I have added prefixWithPackageStructure to my ant hibernate task (weird that this is required) and it now works for all hbm.xml files *except* the above file. I am now completely lost. Xdoclet now inserts that package structures for all properties from the child Subscriber, but not for the parent User. So now, I have a generated hbm.xml file with partly inserted package structures.

I would love some more specifiied error reporting, but I'm still getting the mappingexception: String. Even if I manually change the String entries in the hbm.xml file, to java.lang.String, I'm getting this error.

What am I doing wrong, and why is Xdoclet creating all these faulty files without any error reports?

Marc

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="nl.msw.dates4free.business.entities.User"
        table="Users"
        discriminator-value="U"
    >

        <id
            name="userID"
            column="UserID"
            type="long"
            unsaved-value="0"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-User.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="Subclass"
            type="char"
        />

        <property
            name="email"
            type="String"
            column="getEmail"
            not-null="false"
            unique="false"
        />

        <property
            name="firstName"
            type="String"
            column="getFirstName"
            not-null="false"
            unique="false"
        />

        <property
            name="lastName"
            type="String"
            column="getLastName"
            not-null="false"
            unique="false"
        />

        <property
            name="userName"
            type="String"
            column="getUserName"
            not-null="false"
            unique="false"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-User.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="nl.msw.dates4free.business.entities.Subscriber"
            discriminator-value="S"
        >

        <one-to-one
            name="tokenAccount"
            class="nl.msw.dates4free.business.entities.TokenAccount"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <property
            name="dateAdded"
            type="java.util.Date"
            column="dateAdded"
        />

        <property
            name="mobile"
            type="int"
            column="mobile"
        />

        <property
            name="online"
            type="boolean"
            column="online"
        />

        <property
            name="hits"
            type="long"
            column="hits"
            not-null="false"
            unique="false"
        />

        <property
            name="popularity"
            type="int"
            column="popularity"
        />

        <set
            name="bookmarks"
            table="Bookmarks"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BookmarkUserID"
                  outer-join="auto"
               />

        </set>

        <set
            name="messages"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="DateSent desc"
        >

              <key
                  column="To"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Message"
              />

        </set>

        <set
            name="blockedUsers"
            table="BlockedUsers"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BlockedSubscriberID"
                  outer-join="auto"
               />

        </set>

        <set
            name="favouriteUsers"
            table="FavouriteUsers"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="FavouriteSubscriberID"
                  outer-join="auto"
               />

        </set>

        <one-to-one
            name="settings"
            class="nl.msw.dates4free.business.entities.Settings"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <one-to-one
            name="photo"
            class="nl.msw.dates4free.business.entities.Photo"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <set
            name="photos"
            lazy="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="UserID"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Photo"
              />

        </set>

        <property
            name="receiveSMS"
            type="boolean"
            column="receiveSMS"
        />

        <property
            name="votes"
            type="long"
            column="votes"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-Subscriber.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 10:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you still show me a mapping with String at the place where the exception says it doesn't know the type String!

I don't know what you are doing so i'm just telling you that having "String" in your mappingfiles are wrong - put java.lang.String or string instead and it will work!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Reply
PostPosted: Mon Nov 29, 2004 12:39 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Yes, I understand that. Even when I try to change this into java.lang.String, I get this error. I'm showing you this document also, because this is what I get generated through the Hibernate Xdoclet task which is weird (perhaps this is something for that mailing list then).

Anyway, is the Mappingexception: String error only reported against hbm.xml files that have "String" in the property tag? If this is so, then I don't understand how it can be. Where else can I look?

Why do the method names for these faulty properties get generated by xdoclet as getMethodName in stead of methodName like in the all the other places?


I just ran it against the manually changed file with the same error:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="nl.msw.dates4free.business.entities.User"
        table="Users"
        discriminator-value="U"
    >

        <id
            name="userID"
            column="UserID"
            type="long"
            unsaved-value="0"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-User.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="Subclass"
            type="char"
        />

        <property
            name="email"
            type="java.lang.String"
            column="getEmail"
            not-null="false"
            unique="false"
        />

        <property
            name="firstName"
            type="java.lang.String"
            column="getFirstName"
            not-null="false"
            unique="false"
        />

        <property
            name="lastName"
            type="java.lang.String"
            column="getLastName"
            not-null="false"
            unique="false"
        />

        <property
            name="userName"
            type="java.lang.String"
            column="getUserName"
            not-null="false"
            unique="false"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-User.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="nl.msw.dates4free.business.entities.Subscriber"
            discriminator-value="S"
        >

        <one-to-one
            name="tokenAccount"
            class="nl.msw.dates4free.business.entities.TokenAccount"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <property
            name="dateAdded"
            type="java.util.Date"
            column="dateAdded"
        />

        <property
            name="mobile"
            type="int"
            column="mobile"
        />

        <property
            name="online"
            type="boolean"
            column="online"
        />

        <property
            name="hits"
            type="long"
            column="hits"
            not-null="false"
            unique="false"
        />

        <property
            name="popularity"
            type="int"
            column="popularity"
        />

        <set
            name="bookmarks"
            table="Bookmarks"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BookmarkUserID"
                  outer-join="auto"
               />

        </set>

        <set
            name="messages"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="DateSent desc"
        >

              <key
                  column="To"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Message"
              />

        </set>

        <set
            name="blockedUsers"
            table="BlockedUsers"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="BlockedSubscriberID"
                  outer-join="auto"
               />

        </set>

        <set
            name="favouriteUsers"
            table="FavouriteUsers"
            lazy="true"
            cascade="save-update"
            sort="unsorted"
            order-by="UserName asc"
        >

              <key
                  column="UserID"
              >
              </key>

              <many-to-many
                  class="nl.msw.dates4free.business.entities.Subscriber"
                  column="FavouriteSubscriberID"
                  outer-join="auto"
               />

        </set>

        <one-to-one
            name="settings"
            class="nl.msw.dates4free.business.entities.Settings"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <one-to-one
            name="photo"
            class="nl.msw.dates4free.business.entities.Photo"
            cascade="none"
            outer-join="auto"
            constrained="false"
        />

        <set
            name="photos"
            lazy="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="UserID"
              >
              </key>

              <one-to-many
                  class="nl.msw.dates4free.business.entities.Photo"
              />

        </set>

        <property
            name="receiveSMS"
            type="boolean"
            column="receiveSMS"
        />

        <property
            name="votes"
            type="long"
            column="votes"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-Subscriber.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dude - the exception contains the exact line number and file name for which the parser sees problems ! You must have a hbm.xml with a String in it somewhere.

Regarding xdoclet behavior i don't know - i don't use it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 8:27 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
Check you are modifying the correct files. Sometimes it is easy to accidentally modify a file in the source directory rather than the one on the classpath.


Paul :-)


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