Results 1 to 3 of 3
  1. #1
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default Hibernate subclasses

    I want to map a subclass but I can't do it

    the employee is a SUBCLASS of contact
    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    
    <hibernate-mapping>
       <class name=" entity.Contact" table="contact" >
          <id name="id_contact"  column="id_contact" unsaved-value="0">
             <generator class="identity"/>
          </id>
            <property name="name" column="name" type="string"/>
            <property name="lastname" column="lastname" type="string"/>
            <property name="address" column="address" type="string"/>
            <property name="city" column="city" type="string"/>
            <discriminator column="contact"/>
         <subclass name="entity.Employee" discriminator-value="B">
       
        </subclass>
        </class>
    </hibernate-mapping>
    the error is
    Java Code:
    688  [main] ERROR org.hibernate.util.XMLHelper  - Error parsing XML: XML InputStream(26) 
    The content of element type "class" must match "(meta*,subselect?,cache?
    ,synchronize*,(id|composite-id),discriminator?,(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*)".
    do you know what is the problem?

  2. #2
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default

    The problem is the order of the tags xml, that is the cause of the problem

  3. #3
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default

    bbq is right
    El tag discriminator must be after the id. I send you the correct xml
    Java Code:
    <hibernate-mapping>
       <class name=" entity.Contact" table="contact" >
          <id name="id_contact"  column="id_contact" unsaved-value="0">
             <generator class="identity"/>
          </id>
    <!-- HERE -->
            <discriminator column="contact"/>
    <!--******** -->
            <property name="name" column="name" type="string"/>
            <property name="lastname" column="lastname" type="string"/>
            <property name="address" column="address" type="string"/>
            <property name="city" column="city" type="string"/>
                <subclass name="entity.Employee" discriminator-value="B">
       
        </subclass>
        </class>
    </hibernate-mapping>

Similar Threads

  1. Hibernate, help me
    By Nick15 in forum JDBC
    Replies: 2
    Last Post: 06-05-2008, 03:39 PM
  2. Can I use annotations in superclass, and .cfg.xml files in subclasses in EJB3
    By narayanrec in forum Enterprise JavaBeans (EJB)
    Replies: 4
    Last Post: 01-06-2008, 02:40 AM
  3. Replies: 0
    Last Post: 01-02-2008, 04:24 AM
  4. help needed with methods in subclasses
    By uncopywritable in forum New To Java
    Replies: 4
    Last Post: 08-01-2007, 01:47 PM
  5. Replies: 2
    Last Post: 06-30-2007, 03:01 PM

Posting Permissions

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