facebook

Hibernate hbm.xml file not generated correctly

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #236904 Reply

    madisonDave
    Member

    Hi

    When I select the table and generate Hibernate from it, the hbm.xml file shows an exception. It reads as follows:

    Severity Description Resource In Folder Location Creation Time
    2 The content of element type “class” must match “(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)”. Person.hbm.xml BasicDB/src/org/david line 16 September 8, 2005 10:27:26 AM

    The computer, Eclipse, and Java info are as follows:

    OS

    Windows 2000 5.00.2195
    Service Pack 4

    Eclipse

    Versoin 3.1.0
    Build id: I20050627-1435
    Fresh Install for testing MyEclipse

    Java

    j2sdk1.4.2_05

    MyEclipse
    Version 4.0.0 GA
    Build Id 20050829-4.0.0-GA

    I hope this helps.

    David

    #236916 Reply

    madisonDave
    Member

    Hi

    The original file had the following errors.

    The class entity did not have the package structure correct. Originally the file came out like <class name=”Person” table=”person”>

    Then there was no id element at all. The table column Seq_Id which is an auto-generated PK was not read properly. This element came out as:

    <property name=”seq_id” …./>

    I don’t know whether this is a Hibernate error or rather the auto-generation of the Hibernate files is not correct. Also the hibernate config didn’t have a dialect element.

    David

    <class name=”org.David.Person” table=”Person”>

    <id name=”id” type=”integer”>
    <column name=”Seq_Id” sql-type=”integer” not-null=”true”/>
    <generator class=”identity”/>
    </id>
    <property name=”firstName” column=”First_Name” type=”string” />
    <property name=”lastName” column=”Last_Name” type=”string” />
    </class>

    #238916 Reply

    crajkumar
    Member

    Your hbm.xml file should be the following format

    <?xml version=”1.0″?>
    <!DOCTYPE hibernate-mapping PUBLIC
    “-//Hibernate/Hibernate Mapping DTD 2.0//EN”
    http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd”&gt;
    <hibernate-mapping>
    <class name=”UserDto” table=”users”>
    <id name=”idusers” column=”idusers” type=”int”>
    <generator class=”increment”/>
    </id>

    <property name=”username” column=”username” type=”string” />
    <property name=”password” column=”password” type=”string” />
    <property name=”active” column=”active” type=”int” />
    </class>
    </hibernate-mapping>

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Hibernate hbm.xml file not generated correctly

You must be logged in to post in the forum log in