-->
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.  [ 2 posts ] 
Author Message
 Post subject: Recursive mapping - needs advice
PostPosted: Fri Aug 17, 2007 5:39 am 
Newbie

Joined: Fri Aug 17, 2007 5:17 am
Posts: 2
Hello.

Hibernate version:hibernate-3.2

Mapping documents:
<class name="bus.Topic" table="perfomer">
<id name="perfomerId" column="perfomerid" unsaved-value="-1">
<generator class="identity"/>
</id>
<many-to-one name="parent"
class="bus.Topic"
cascade="none"
column="perfomerpid"
not-null="true"/>

<set name="childrenInternal" inverse="true" cascade="all">
<key column="perfomerpid"/>
<one-to-many class="bus.Topic"/>
</set>

<set name="albumsInternal" inverse="true" cascade="all">
<key column="perfomerid"/>
<one-to-many class="bus.Album"/>
</set>

<property name="pefName" column="pname" type="string"/>
<property name="desc" column="description" type="string"/>
</class>



Name and version of the database you are using:RostgreSQL

The SQL of a table :
CREATE TABLE perfomer
(
perfomerid bigserial NOT NULL,
perfomerpid integer,
pname character varying(50),
description text,
CONSTRAINT pk3 PRIMARY KEY (perfomerid),
CONSTRAINT refperfomer20 FOREIGN KEY (perfomerpid)
REFERENCES perfomer (perfomerid) MATCH SIMPLE

)


By now the current decision works like a cash of database, i can get through the childrenInternal to any child..and to the child of child..but i don't need it, because i got all problems concerned with a cash
(add,update,delete(if i decide to use only an instance of Topic->minimum directs to database)) , and it takes a lot of time to get data from database.
I need in childrenInternal only one level depth.
Instead of this, hibernate loads all data from database in an instance of class Topic.

Have some ideas?
Thnk!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 22, 2007 4:01 am 
Newbie

Joined: Fri Aug 17, 2007 5:17 am
Posts: 2
Please, give me some advice, may be I need to separate class topic into two classes : child and parent.

Solution

default-lazy=true

add to web.xml filter(to make session "alive" during all request) these lines
<filter>
<filter-name>hibernateSessionFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateSessionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.