-->
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.  [ 3 posts ] 
Author Message
 Post subject: Please help, Problem with collections
PostPosted: Wed Aug 03, 2005 10:03 am 
Newbie

Joined: Wed Aug 03, 2005 9:48 am
Posts: 2
I have a huge problem with a collection (bag) in hibernate in a rather complex data-collector program using a database with more than a million data. So it is important only to load neccesary data through hibernate.

Now to the problem:

I have an energycase with a collection of subcases:

<bag name="subcases" table="EnergyCaseSubcases">
<key column="id"/>
<many-to-many class="EnergySubcase" column="subcase"/>
</bag>

A subcase points to a channel and before I can delete the channel I have to check if it exists in any energycases - if it does I have to give a message to the user. From a channel I can find the subcase, but not the energycase from the subcase.

In SQL it is quite easy:

select * from Energycase where id in (select subcase.id from EnergyCaseSubcases subcase where subcase='a known id'

So my problem is to go backward using a bag, how can I do that?

Note: since there is copyrights on the program I can't write the java-clases and hibernate mappings in more details, sorry!


Top
 Profile  
 
 Post subject: why do not use SQL
PostPosted: Wed Aug 03, 2005 10:49 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
For the check you can use your SQL
http://www.hibernate.org/hib_docs/v3/re ... -nativesql


Top
 Profile  
 
 Post subject: We have a design with no SQL-queries at all
PostPosted: Wed Aug 03, 2005 11:05 am 
Newbie

Joined: Wed Aug 03, 2005 9:48 am
Posts: 2
Our design is developed so we could change to use another java-database layer and the program must be able to run on several different databases.

Therefore will we not use SQL directly - all our call is made through transaction string in HQL which ensure that the call will work on all databases hibernate support.

So we will only use plain SQL if we can't do the check in any other ways. I am about to make a usable way now, but it will retrieve the same information from the database several times - and lots of it is uneeded.

Any other have a solution?


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

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.