Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

1:M lost getting lists

 
graham king
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
graham king
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makes better sense now. What a difference a day makes. Here's another version of the query:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic