File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Mapping Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping Question " Watch "Mapping Question " New topic

Mapping Question

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 159
How to build Hibernate Mapping as below shown?

For example, Should I use join-subclass or something else?
Table Rule has a primary key pair RuleTypeKey and Key
Table Risk_Group refers Table Rule's Primary Key pair as foreign key but
only Key as its Primary key.

Table Rule

PK RuleTypeKey
PK Key

PK,FK1 RuleTypeKey
Fk1 Key

--------------Below is my mapping file for -----------------
But I always get exception as org.hibernate.MappingException: broken column mapping for: of: Rule

<id name="key" type="java.lang.String" column="KEY">
<meta attribute="field-description"> generator-class="assigned"
type="java.lang.String" column="KEY"

<generator class="assigned" />

<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
<!-- bi-directional one-to-one association to Rule -->
<many-to-one name="rule"
class="Rule" unique="true" fetch="join">
<meta attribute="field-description">
@hibernate.many-to-one unique="true" @hibernate.column
name="RULE_TYPE_KEY" @hibernate.column name="KEY"

<column name="RULE_TYPE_KEY" />
<column name="KEY" />

public class Walter { public boolean is_Working_Now (boolean is_boss_Coming) { return is_boss_Coming; }
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

join-subclass is for mapping inheritance. So you have a Java Objec thtat extends another Java Object.

So the Parent has "fields" that the children want to inherit.

Then it becomes a decision based on how the tables are defined. Is there just one table, or for each subclass there is a seperate table. Or is the database third normal form.

Is this an example of one of those above?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Mapping Question
It's not a secret anymore!