Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate mapping error?

Tags:

xml

hibernate

I've created a hbm.xml file but it's giving me an error:

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

Here's the code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="edu.byu.training.domain.ProductFlsko" table="PRODUCTFLSKO" schema="GAATTRAINING">
        <property name="productId" column="PRODUCT_ID"/>
        <property name="product" column="PRODUCT"/>
        <property name="description" column="DESCRIPTION"/>
        <property name="price" column="PRICE"/>
        <property name="rowNumber" column="ROW_NUMBER"/>

        <query name="get.By.Id" cacheable="true">
            select ProductFlsko
            from edu.byu.training.domain.ProductFlsko prod
            where prod.productId = :id
        </query>
    </class>
</hibernate-mapping>

I can't figure this out for the life of me...

like image 411
Ryan D Avatar asked Mar 31 '26 16:03

Ryan D


1 Answers

The class mapping must contain an id or composite-id, see Identifiers in the documentation.

Your id is probably productId.

There are several identity generators.

<class name="edu.byu.training.domain.ProductFlsko" table="PRODUCTFLSKO" schema="GAATTRAINING">
    <id name="productId" column="PRODUCT_ID">
        <generator class="native" />
    </id>
    <property name="product" column="PRODUCT"/>
    <property name="description" column="DESCRIPTION"/>
    <property name="price" column="PRICE"/>
    <property name="rowNumber" column="ROW_NUMBER"/>

    <query name="get.By.Id" cacheable="true">
        select ProductFlsko
        from edu.byu.training.domain.ProductFlsko prod
        where prod.productId = :id
    </query>
</class>
like image 121
Lachlan Roche Avatar answered Apr 03 '26 17:04

Lachlan Roche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!