Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Inserting data using HQL on multiple tables.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to construct a Hibernate object that refers to two database tables. I have one object called Attribute and another called Activity. The object Attribute is read only, and has a Many-to-Many relationship with Activity. The following is the definition of Attribute



Here is the Activity hbm.xml file



My questions are
  • How do you (using HQL) insert AND delete a single value into the relationship table (one attribute ID, one activity ID)?

  • UPDATE: Considering the fact that HQL inserts only support inserts from another table, how do you reference the foreign keys in the relationship table (that is the attribute and activity identities) in HQL?
    Here is my attempt -

    Error message - Attribute.activities isn't map!

  • Can I use a java.util.Set in the Attribute object only as a place holder and not load data into it, because I rather load the relationship in a separate object?
  • Do I just use <sql-query> to load the other object by specifying the bean properties of the other object?


  • Thanks
    Patrick
     
    You may have just won ten million dollars! Or, maybe a tiny ad.
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic