This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes 1:M lost getting lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "1:M lost getting lists" Watch "1:M lost getting lists" New topic
Author

1:M lost getting lists

graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
I've just started using Hibernate and am having problems getting the many side of a relationship. I promise I'll buy a book soon, but, in the meantime I've been using the web as my main resource...

Here's the problem:
I used an ant script to reverse eng the db which is in use. Chapter 4. Ant Tools. Great script. I hate writing mapping files. This also helped: hbm2java

This gave me a slew of mapping files, but, now I'm not able to get the many side of the relationship using HQL?

Here's part of each mapping file:


I was able to figure out how to get the 1 side but not the many. Tried based on: Hibernate Querying 101 and HibernateUtil Here's how I'm accessing the tables:


The above gives me the following:


Here's the class files:


Please help! I'm burnt.

Graham


write, revise, re-write, revise, again...<br />write, revise, re-write, revise, again...
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
The following HQL query ended up working:


There is a db.table.column named reference which needed to be enclosed in [reference]...
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
I spoke too soon. There's another field:


Results in:


Which I guess is unsupported with MS SqlServer. So I changed it to:


-- but i didn't chane the VO to match... no wonder it's called ranting like an incoherent fool! :roll:

And now I get the following:


Is there a way to solve this?

TIA,
Graham
[ February 21, 2006: Message edited by: graham king ]
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
ok, just let a ranting fool, rant!

i upgraded the driver to ms sql server 2005.

re-changed all string(clobs) back to clobs.

told the query to list() instead of uniqueResult().

and removed the session.close();

Alls Good!
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Makes better sense now. What a difference a day makes. Here's another version of the query:
 
GeeCON Prague 2014
 
subject: 1:M lost getting lists