-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping of sets, and calling a parameterised stored proc
PostPosted: Tue Jul 31, 2007 7:12 am 
Newbie

Joined: Tue Jul 31, 2007 7:08 am
Posts: 2
Location: Tarrytown, NY
This should be easy to do in Hibernate, but I can't figure it out. I have a SQL table called MEMBER that has, among other fields, these two:
MEMBER_ID (a long integer, primary key)
MEMBER_NAME (a string)

I also have a MEMBER_ATTRIBUTE table with the following fields:
ATTRIBUTE_NAME (a string)
MEMBER_ID (long integer, refers to member_id in my MEMBER table)

Two key pieces of information: The ATTRIBUTE_NAME value in my member_attribute table is *not* a primary key; there are multiple members for any named attribute. i.e. this table might contain records like:
"swimmer", 1
"swimmer", 2
"runner", 1
"runner", 4

The other key piece of information is that a member may have more than one attribute. Using the data shown just above, member #1 is both a "swimmer" and a "runner".

My instincts tell me that I should build a third table listing the unique attribute values. It would have two fields:
ATTRIBUTE_ID
ATTRIBUTE_NAME

My member_attribute table could then be two fields:
ATTRIBUTE_ID
MEMBER_ID

I could then have a Java class called 'memberAttribute' that would have the identifying 'attributeId' field, a String 'attributeName' field, and a HashSet of members that match that attribute.

All well and good, but I can't match this design to a working set of XML maps. Could anyone throw me a bone?

On a related note, I've built a stored procedure that can take, as a String parameter, an attribute, and will return all the fields for the members that match that attribute. The Hibernate documentation mentions the <sql-query> tag, but does not explain (at least not well enough for a beginner like me) how to tag a query's parameters.

Any ideas would be welcome.

_________________
Java - write once, debug everywhere.


Top
 Profile  
 
 Post subject: Very much like the first chapter of the tutorial
PostPosted: Tue Jul 31, 2007 3:59 pm 
Newbie

Joined: Tue Jul 31, 2007 7:08 am
Posts: 2
Location: Tarrytown, NY
My table associations are very much like the example in the first chapter of the tutorial, so I'll work from that.

Still am unclear on how to XML a parameterized stored procedure, though.

_________________
Java - write once, debug everywhere.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.