-->
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: Confused! Need advice on mapping multiple 1-to-n relation
PostPosted: Mon Mar 08, 2004 3:45 pm 
Beginner
Beginner

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 20
Hi,

First, as a newbie in Hibernate, I'd like to thank all the people here - this is one of the best open-source sites I've seen - well documented and questions get answered quickly. I've been able to solve many issues with the initial setup and test without posting a single question.

I'm building an attachment handling module for my application that many entities contain a list of attachments (may be as large as 10MB or more). The module should implement upload/download functionalities using stream -> Blob conversion.

My first instinct is to map the attachments as a component collection of each entity because this can provide best performance (uploading attachments causes lock actions on the table).

But when I started to create the mapping, I realized that due to the way that Blobs are handled, I need to first create a persisted Attachment object with empty Blob content, then lock&upload and then associate it with its parent entity object.

Since many entities have attachments, it seemed impossible to map a single "Attachment" type to many "collection value" tables while letting Hibernating know which table should be used for a specific Attachment instance.

So an one-to-many relation mapping seems inevitable - which means that I'll have a single table for all attachments, with a structure like this:

TABLE ATTACHMENTS
COLUMN UNID PRIMARYKEY NUMBER
COLUMN PARENTUNID NUMBER
COLUMN FILENAME VARCHAR
COLUMN CONTENTTYPE VARCHAR
COLUMN CONTENT BLOB

What I'd like to be advised are:
1. Is my concern valid on using "value collection" type mapping? is it possible in Hibernate 2.1?

2. If I use the "one-to-many" type mapping and tread attachment as a independant entity, holding all attachments in a single table, will I get a performance hit when users upload attachments frequently?

Thanks in advance,
Dan


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.