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 7931767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:49:03+00:00 2026-06-03T20:49:03+00:00

I’m new to hibernate and I came a cross a problem. I’ve read all

  • 0

I’m new to hibernate and I came a cross a problem. I’ve read all throu the starter guides etc. on the hibernate website and I still can’t come up with a solution.

I have a class like this:

public class ResultTree {
String attrName;
Map<String, ResultTree> valueMap;
String classValue;
int caseQuant;
Set<Map<String, String>> otherRules;

public String getAttrName() {
    return attrName;
}
public void setAttrName(String attrName) {
    this.attrName = attrName;
}
public Map<String, ResultTree> getValueMap() {
    return valueMap;
}
public void setValueMap(Map<String, ResultTree> valueMap) {
    this.valueMap = valueMap;
}
public String getClassValue() {
    return classValue;
}
public void setClassValue(String classValue) {
    this.classValue = classValue;
}
public int getCaseQuant() {
    return caseQuant;
}
public void setCaseQuant(int caseQuant) {
    this.caseQuant = caseQuant;
}
public Set<Map<String, String>> getOtherRules() {
    return otherRules;
}
public void setOtherRules(Set<Map<String, String>> otherRules) {
    this.otherRules = otherRules;
}

}

How should a hbm.xml for a class like this look? I’m free to create any data structure.

Thanks for the help,
MM

  • 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-06-03T20:49:04+00:00Added an answer on June 3, 2026 at 8:49 pm

    With the help of Ranna’s solution I managed to model the class by dividing it to two separate classes:

    public class ResultTree {
    private Long id;
    private String attrName;
    private Map<String, ResultTree> valueMap;
    private String classValue;
    private int caseQuant;
    private Set<Rule> otherRules;
    }
    

    and

    public class Rule {
    private Long id;
    private Map<String, String> terms;
    private ResultTree tree;
    private String classValue;
    }
    

    hbm.xml has the following form:

        <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="lib.experiment.result">
        <class name="ResultTree" table="RESULT_TREE">
            <id name="id" column="RESULT_TREE_ID" type="long" />
            <property name="attrName" type="string" column="ATTR_NAME" />
            <property name="classValue" type="string" column="CLASS_VALUE" />
            <property name="caseQuant" type="int" column="CASE_QUANT" />
            <map name="valueMap" table="RESULT_TREE_LEAF" lazy="false">
                 <key column="RESULT_TREE_ID"/>
                 <map-key column="ATTR_VALUE" type="string"/>
                 <many-to-many class="ResultTree" />
            </map>
            <set name="otherRules" table="RULE" lazy="false">
                <key column="RESULT_TREE_ID"/>
                <one-to-many class="Rule"/>
            </set>
        </class>
        </hibernate-mapping>
    

    and

        <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="lib.experiment.result">
        <class name="Rule" table="RULE">
            <id name="id" column="RULE_ID" type="long" />
            <property name="classValue" column="CLASS" type="string" />
            <map name="terms" table="RULE_TERM" lazy="false">
                 <key column="RULE_ID"/>
                 <map-key column="ATTR_NAME" type="string"/>
                 <element column="ATTR_VALUE" type="string"/>
            </map>
            <many-to-one name="tree" class="ResultTree" lazy="false">
                <column name="RESULT_TREE_ID"/>
            </many-to-one>
        </class>
        </hibernate-mapping>
    

    Thanks a lot for the help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from

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.