-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping issue - more tables than classes
PostPosted: Wed Apr 26, 2006 2:27 am 
Newbie

Joined: Mon Apr 24, 2006 4:08 am
Posts: 5
Hi!

I tried to get an answer at several locations, so I think I have to spend a credit to get an answer here...maybe ;-).

Well, suggest I want to model a letterhead. In Java I would generate a class like:

class Letterhead {

private String title;
private String address; [Mr. or Mrs.]
private String name;
private String surname;

....gettter/setter....
}

I would create an DB scheme like:

table letterhead (

letterhead_id: int;
name:varchar
surname: varchar;
title_id: int;
address_id: int;
)

table address (

address_id: int;
label: varchar;
)

table title (

title_id: int;
label: varchar;
)

I do this, because I want to have a normalized scheme. I figured out, that it is possible to have a mapping with more classes than tables in Hibernate, but not a mapping between more tables than classes.

I like to have hibernate to fill the fields of my letterhead class with the corresponding labels form the underlining foreign key relation. In my previous project that was be done by the application logic.

I do not want to have a separate class for address or title, because I like to have my domain model 'small'. Most of the time the model is complex enough without these additional classes.

Is there a way to do the mapping with hibernate or have I to do it again with good old JDBC coding? Honestly I would hate the JDBC coding after I learned hibernate ;-).


Thanks,

Danny


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.