-->
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: DAO Classes and Foreign Key
PostPosted: Tue Feb 05, 2008 5:20 am 
Beginner
Beginner

Joined: Tue Jan 22, 2008 11:33 am
Posts: 46
Hi,

I'm a kind of trapped. I thought a lot about a smart application design and came up with the following solution:

I got a package (utility) which contains the session manger.
another one which contains folders for entity classes, mappings and Data Access Objects. The later also takes care of calling the session manager.
On top I can put my application classes, which use the two packages "underneath". I think it's nice but it does not work.
Almost all entities have foreign key. Therefore calling a DAO Method GetItems returns me all objects but each one has foreign key relation.
When I want to use this foreign key column there is no session connection, because after the DAO Method returned all objects the session was closed.
example:
Code:
            IList result = GetItems(typeof(OrganizationalUnit));

            foreach (OrganizationalUnit ou in result)
                if (ou.OrganizationalUnitTypeId.ToString() == "group")
                    ouList.Add(ou);

In this example OrganizationalUnitTypeId is a foreign key. An exception is thrown "Could not initialize proxy - the owning Session was closed."
How could I solve this problem

Thanks for your help in advance

antoschka


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.