aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping Question " Watch "Mapping Question " New topic
Author

Mapping Question

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 148
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
--------------------
Risk_Group

PK,FK1 RuleTypeKey
Fk1 Key

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



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

</meta>
<generator class="assigned" />
</id>


<!-- 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"
</meta>

<column name="RULE_TYPE_KEY" />
<column name="KEY" />
</many-to-one>


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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Mapping Question
 
Similar Threads
Association mapping
many-to-one relationship to non-PK field
How to solve Repeated column in mapping for entity:
Integrity constraint violation: for Hibernate Insert
Use of set tag in Hibernate mapping file for foreign key