• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inserting data using HQL on multiple tables.

 
Patrick Fong
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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic