-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Populating associations from views
PostPosted: Sun Sep 24, 2006 7:24 pm 
Newbie

Joined: Mon Aug 29, 2005 1:14 am
Posts: 10
Hibernate version: Hibernate 3.0

I want to sometimes populate objects and their associations from a view, but also sometimes populate them "normally", allowing Hibernate to generate the SQL and joins.

I have a standard parent-child, one-to-many relationship. For existing objects in the database, the normal Hibernate mapping suffices.

But for objects that don't yet exist, I have a view that provides "potential" objects. I would like to populate from the views, do some processing to complete the object graph, then save the objects into the database, after some processing.

How can I get Hibernate to populate from the views?


In more detail: A Questionnaire object has a (1-M) association to set of Questions, each of which has a (1-M) association to a Set of Answers. No problem here, the normal Hibernate populating works fine.

Each Questionnaire also has a (1-M) association to a Set of AnsweredQuestionnaire, which has a (1-M) association to a set of AnsweredQuestions.

Each AnsweredQuestion has a (1-1) association to a Question and a (1-1) association to an Answer. (It's a M-M table, essentially.)

It's the AnsweredQuestionnaire and AnsweredQuestions I want to populate from the view; this will provide as-yet-not-existing-in-the- database AnsweredQuestion object, and its associated Set of as-yet-not-existing-in-the-database AnsweredQuestions.


After setting the (1-1) link to each AnsweredQuestion's answer, I'll cascade save the AnsweredQuestionnaire to the database.

How do I write a Hibernate mapping that populates an AnsweredQuestionnaire and its Set of AnsweredQuestions from views?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.