M
M
Maks Burkov2017-02-20 20:36:20
Java
Maks Burkov, 2017-02-20 20:36:20

Working with hbm.xml, how to properly map classes?

I'm trying to map two classes in one scheme .. The Address class throws an error, who can explain the error itself?

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)*)" .


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

    <class name="com.demo.User" table="Users">

        <id name="id" type="int" column="user_id">
            <generator class="increment"/>
        </id>

        <property name="first_name" column="first_name" type="java.lang.String"/>
        <property name="last_name" column="last_name" type="java.lang.String"/>
        <property name="salary" column="salary" type="int"/>

    </class>

    <class name="com.demo.Address" table="Address">
        <property name="street" column="street" type="java.lang.String"></property>
        <property name="city" column="city" type="java.lang.String"></property>
        <property name="country" column="country" type="java.lang.String"></property>
    </class>

</hibernate-mapping>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-02-20
@Maks00088

where is the key in the entity Address?
but in general, if the requirement to use hbm.xml is not dictated by the customer (I feel that is just the case), I would already start studying JPA instead :) and I would not cover xml, but use annotations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question