-->
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.  [ 3 posts ] 
Author Message
 Post subject: Simple Collection Mapping Question
PostPosted: Thu Mar 10, 2005 3:15 pm 
Newbie

Joined: Wed Jul 28, 2004 6:13 pm
Posts: 12
OK this is just a simple usage question and I apologize for posting something so basic. I'm not having any problems doing some object->object type matching but the simple stuff is what's getting me. Here's an example:

example database tables:

create table person (
id char(32) primary key,
name varchar(128),
);

create table aliases (
personid char(32),
alias varchar(128)
);

Make sense so far? The person.id is a hibernate generated ID, no problem. What I want to do, simply, is have a property on my Person class called "aliases" that's a List. So it looks like I'd normally use a <bag> to do this. The problem I'm having is trying to wrap my brain around something simple like this. I just know I'm missing something fundamental in the docs.

I can do mapping between two tables, like person and "pets" or something, then have a third table that has a personid and petid.. things like that no problem. I just want to do something simply like have a java.util.List of Strings containing aliases.

So could someone push me in the right direction on what sort of mappings I'd need for do this? Any simple suggestions would help.

Again sorry for such a simple question.. but its driving me nuts :)

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 3:36 pm 
Newbie

Joined: Wed Jul 28, 2004 6:13 pm
Posts: 12
Here's a followup example. In the documentation it has this snippet of code:

Code:
<bag name="sizes" table="SIZES" order-by="SIZE ASC">
    <key column="OWNER"/>
    <element column="SIZE" type="integer"/>
</bag>


OK that seems to be what I need. This appears as though it would return a List of integers for the "sizes" property. But how would I go about saving the data INTO the "SIZES" table? There's no class associated with it.. so I cant just set some properties on a bean and do a session.save() for that. I'd assume by looking at this. .the table format would be something similar to:

create table SIZES (
owner char(32) primary key,
size int
);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 3:48 pm 
Newbie

Joined: Wed Jul 28, 2004 6:13 pm
Posts: 12
Should have searched a little more. Found this topic where this person is basically asking the same question and posts a followup. Maybe he's right.. a nice set of example mappings on the Wiki wouldn't be a bad idea :)

http://forum.hibernate.org/viewtopic.php?t=939005

Sorry for the simple question.. ignore me and go back to your Hibernate(ing).


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

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.