• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

1:M lost getting lists

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Makes better sense now. What a difference a day makes. Here's another version of the query:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic