Results 1 to 2 of 2
  1. #1
    valery is offline Member
    Join Date
    Jul 2007
    Posts
    32
    Rep Power
    0

    Default help with inheritance in hibernate

    I have the table "Person" in my data base
    I'm trying to map in hibernate the Person object and its subclasses
    Java Code:
    <hibernate-mapping>
        <class name="Model.Person"  table="Person">
            <id name="id" type="integer" column="idPerson">
                <generator class="native"/>
            </id>
            <property name="name" type="string" column="Name"/>
            <property name="lastname" type="string" column="Lastname"/>
           <property name="address" type="string" column="address"/>
            <property name="email" type="string" column="email"/>
                <discriminator column="type" type="character"/>
            <subclass name="Model.Enterprise.Boss" discriminator-value="C"/>          
        </class>
    </hibernate-mapping>
    When I try to map:
    Java Code:
    13:05:46,437  INFO Configuration:553 - Reading mappings from resource :
     Data/person.hbm.xml
    13:05:46,500 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(17) 
    The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(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)*
    ,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,
    sql-delete?,filter*,resultset*,(query|sql-query)*)".
    Error al crear SessionFactoryorg.hibernate.InvalidMappingException: 
    Could not parse mapping document from resource Data/person.hbm.xml
    Exception in thread "main" java.lang.ExceptionInInitializerError
    thanks

  2. #2
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    try with this:
    Java Code:
    el mapeo me quedo asi
    
    <hibernate-mapping>
        <class name="Model.Person"  table="Person">
            <id name="id" type="integer" column="idPerson">
                <generator class="native"/>
            </id>
       [COLOR="Red"]  <discriminator column="type" type="character"/>[/COLOR]
            <property name="name" type="string" column="Name"/>
            <property name="lastname" type="string" column="Lastname"/>
           <property name="address" type="string" column="address"/>
            <property name="email" type="string" column="email"/>
           
            <subclass name="Model.Enterprise.Boss" discriminator-value="C"/>          
        </class>
    </hibernate-mapping>

Similar Threads

  1. inheritance and aggregation
    By java_fun2007 in forum New To Java
    Replies: 3
    Last Post: 12-13-2007, 01:36 PM
  2. Inheritance
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-07-2007, 06:08 PM
  3. Multiple Inheritance
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-01-2007, 10:04 PM
  4. Replies: 2
    Last Post: 06-30-2007, 03:01 PM
  5. Inheritance in GUI
    By Marty in forum SWT / JFace
    Replies: 2
    Last Post: 05-11-2007, 12:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •