-->
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.  [ 13 posts ] 
Author Message
 Post subject: org.xml.sax.SAXParseException: The content of element type
PostPosted: Thu Sep 25, 2003 11:19 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi,

I

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 11:21 am 
Newbie

Joined: Thu Sep 25, 2003 11:09 am
Posts: 6
Location: Auburn Hills, MI, USA
I guess that the id element should be placed before all property elements.

-Balaji


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 11:26 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Yip, I'd go with what gbalaji said. Although a little hard to read for some, the exception does say that the <id> tag must always come before properties.

-G


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 12:48 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Thank you Balaji.

Now It

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:19 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
It may be that you need to change you <bag> to the following, and I am just guessing as to a possibility.

Code:
<bag name="users" [b]cascade="all"[/b] inverse="true" lazy="true">
    <key column="id_template"/>
    <one-to-many class="br.com.proj.dao.register.User"/>
</bag>


Also, it could be that your Template class should have a getUsers() and setUsers() method - not sure if you do or don't. Of course, these would both be of a collection type, e.g. java.util.List

Worth a try, till one of the Hibernate team or someone else can give a more precise explanation.

-G


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:21 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Sorry...remove the Bold tags in the code...still getting used to the forum format. :P

-G


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 9:26 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Did a little search of the forum, and found quite a few people that came up with this problem, and it always seems to come back to one thing:

Mapping a primitive type to a database field that can be null.

Make sure to set not-null="true" for all your primitave types (in your property) in your hbm file(s).

And, if like me, when you have to later add a new property-field mapping that is a primitive, make sure to set the value of all the rows in your database, otherwise when you try to do a load on them, Hibernate will try to assign a null value to a primitive, and you'll get this exception again.

A simple: update TABLE set FIELDNAME = 0; should suffice, if 0 is your default value for that field. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 12:43 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi,

I configured the values of primitive type with property not-nul="true",
but the error is the same.
In the User bean, I can to have um parent_user and your
children (subordinates) too.

The user mapping is:


Code:
<hibernate-mapping>
    <class name="br.com.proj.dao.register.User" table="users">
      <id name="idUser" column="id_user">
         <generator class="assigned"/>
      </id>
      <property name="dtExclusion" column="dt_exclusion"/>
        <property name="dtInclusion" column="dt_inclusion"/>
        <property name="name" column="name"/>
        <property name="password" column="password"/>
        <property name="stUser" column="st_user" not-null="true"/>
      <property name="nbEmployee" column="nb_employee" not-null="true"/>
        <many-to-one name="department" column="id_department" class="br.com.hst.dao.register.Department"/>
        <many-to-one name="template" column="id_template" class="br.com.proj.dao.register.Template"/>
      <many-to-one name="parentUser" column="id_parent_user"
         class="br.com.proj.dao.register.User"/>
      <bag name="subordinates" cascade="all" inverse="true" lazy="true">
         <key column="id_parent_user"/>
         <one-to-many class="br.com.proj.dao.register.User"/>
        </bag>
    </class>


I

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Turn the reflection optimizer off, and you will see a more helpful exception message. The problem will be in your Java class definition somewhere.


Top
 Profile  
 
 Post subject: I FORGOT
PostPosted: Fri Sep 26, 2003 1:10 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
I forgot a thing:

I

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:34 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi Brannor McThife,

The alternative:

A simple: update TABLE set FIELDNAME = 0; should suffice, if 0 is your default value for that field. :)

Is this the only way for this????

thanks

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 5:55 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Tads, no, it isn't the only way.

It depends on your database. e.g. in MS SQL you simply set the default value of the new field to whichever you choose, and it will insert that value for all the existing rows. I'm not too familiar with Oracle, but I'm sure you can do the same there.

:)

-G


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 7:25 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
I understood,

I

_________________
Tads


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