Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:23:48+00:00 2026-05-23T14:23:48+00:00

I would like to establish a relationship many-to-one between two fields on database. I

  • 0

I would like to establish a relationship many-to-one between two fields on database. I am using PostgreSQL database and Hibernate. The tables are ApplicationField and Device. The first one has 2 columns: AppFieldId and Name. The second one has NodeId, Description and AppFieldId. The hibernate mapping for ApplicationField is:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 05-may-2011 13:21:52 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.cartif.database.ApplicationField" table="APPLICATIONFIELD">
    <id name="iAppFieldId" column="applicationfieldid" type="java.lang.Integer">
        <generator class="sequence">
            <param name="sequence">s_applicationfield</param>
        </generator>
    </id>
    <property column="name" lazy="false" name="name" type="java.lang.String"/>
    <set name="devices">
        <key column="appfieldid" />
        <one-to-many column="nodeid" class="com.cartif.zigbee.device.Device"/>
    </set>
</class>
</hibernate-mapping>

And for Device:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                               "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 07-abr-2011 13:29:19 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.cartif.zigbee.device.Device" table="Device">
    <id column="nodeid" name="iIdentifier" type="java.lang.Integer"/>
    <property column="description" generated="never" lazy="false" name="description" type="java.lang.String"/>
    <set name="appField">
        <key column="nodeid"/>
        <many-to-one column="appfieldid" class="com.cartif.database.ApplicationField"/>
    </set>
</class>
</hibernate-mapping>

On Java classes I have a List devices on ApplicationField class and ApplicationField appField on Device class. However, when I try to create a sessionFactory, I obtain an exception like:

org.xml.sax.SAXParseException: Attribute "column" must be declared for element type "one-to-many".

How should I do the relationship between the tables?

Thanks a lot!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:23:49+00:00Added an answer on May 23, 2026 at 2:23 pm

    I guess the relationship is as follow:

    One ApplicationField has many Devices.
    One Device can refer to Many ApplicationField.

    If It is true, then there are some mistakes in your mapping.

    Replace devices set with following (change in Id column):

    <set name="devices">
            <key column="applicationfieldid" />
            <one-to-many class="com.cartif.zigbee.device.Device"/>
    </set>   
    

    Update many-to-one mapping as:

    <many-to-one name="appField" column="applicationfieldid" class="com.cartif.database.ApplicationField"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to establish a many-to-many relationship with a constraint that only one
I would like to clarify the relationship between latent Dirichlet allocation (LDA) and the
I would like to know how to establish the link between eclipse - tomcat
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to sort an array in ascending order using C/C++ . The
I would like to have a reference for the pros and cons of using
I have a file on a secured site I would like to download using
We are starting a new ASP.NET MVC project and we would like to establish
I would like to connect to the database from a Drupal 7 module. Currently
Even if UDP is connection-less, I would like to establish some kind of connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.